本文整理汇总了TypeScript中@soil/dom.h.form方法的典型用法代码示例。如果您正苦于以下问题:TypeScript h.form方法的具体用法?TypeScript h.form怎么用?TypeScript h.form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@soil/dom.h
的用法示例。
在下文中一共展示了h.form方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: showTopFoods
window.open(url, '_blank')
} else {
location.href = url
}
return true
}
}
}
}
},
series: [{}]
})
document.body.appendChild(h.div({className: 'top-foods v box'}, [
h.form({className: 'spaced h box'}, [
Object.assign($nutrientSelect, {className: 's3'}),
$unitParamSelect
]),
h.div({className: 'outer-chart-wrapper s1'}, [
$chartWrapper
])
]))
function showTopFoods(nutrientId: string, unit: api.NutrientReferenceUnit) {
get<api.TopFood[]>(`${serverUrl}/nutrients/${nutrientId}/foods?unit=${unit}`).then(topFoods => {
$chartWrapper.classList.remove('hidden')
const data = topFoods.map(f => ({
...f,
name: f.Long_Desc,
y: f.Nutr_Val,
color: f.color
示例2: save
import {h} from '@soil/dom'
import {icon} from '../shared/dom/icon'
const page = h.div({className: 'page'}, [
h.h1({className: 'main-title'}, ['Your profile']),
h.form({}, [
h.ul({className: 'field-list'}, [
h.li({}, [
h.label({htmlFor: 'field-age'}, ['Age']),
h.input({id: 'field-age', type: 'number', min: '0', max: '150'})
]),
h.li({}, [
h.label({htmlFor: 'field-gender'}, ['Gender']),
h.select({id: 'field-gender'}, [
h.option({value: 'M'}, ['Male']),
h.option({value: 'F'}, ['Female'])
])
])
]),
h.hr(),
h.button({onclick: () => save()}, [icon('save'), 'Save'])
])
])
function save() {
// TODO
console.log('Saving...')
}
document.body.appendChild(page)