本文整理汇总了TypeScript中mithril类的典型用法代码示例。如果您正苦于以下问题:TypeScript mithril类的具体用法?TypeScript mithril怎么用?TypeScript mithril使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了mithril类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
const comp2 = function (vnode) { // vnode is inferred
return {
view ({attrs: {title, description}}) { // Comp2Attrs type is inferred
return [m('h2', title), m('p', description)]
}
}
} as FactoryComponent<Comp2Attrs>
开发者ID:cronon,项目名称:DefinitelyTyped,代码行数:7,代码来源:test-factory-component.ts
示例2: m
view: vnode => {
const onclick = vnode.attrs.closeWindow;
const onmousedown = e => e.stopPropagation();
return m("td.window-buttons", [
m("button.close-button", { onclick, onmousedown }, [
m("i.icon-cancel-circled")
])
])
}
开发者ID:phincallahan,项目名称:personal-website,代码行数:9,代码来源:WindowButtons.ts
示例3: setTab
const children = names.map((n, i) => {
const attrs = {
onclick: () => setTab(i),
onmousedown: (e: MouseEvent) => e.stopPropagation()
}
return i === activeIndex
? m("div.window-tab-active", attrs, n)
: m("div.window-tab", attrs, n);
});
开发者ID:phincallahan,项目名称:personal-website,代码行数:9,代码来源:WindowTabs.ts
示例4: m
view: vnode => {
const { err, code } = vnode.attrs;
if (err !== undefined) {
return m(Err, {err})
} else if (vnode.attrs.code) {
return m(Loaded, {code})
} else {
return m("div.euler-code-wrapper", "Loading...");
}
}
开发者ID:phincallahan,项目名称:personal-website,代码行数:10,代码来源:EulerSolution.ts
示例5: m
view: vnode => {
const { x, y } = vnode.state;
const style = { top: `${y}px`, left: `${x}px` };
const tab = vnode.attrs.tabs[vnode.state.activeIndex];
const attr = typeof tab.attr === "function"
? tab.attr()
: tab.attr;
const key = vnode.attrs.k;
const focusWindow = () => vnode.attrs.focusWindow(key);
const closeWindow = () => vnode.attrs.closeWindow(key);
return m("div.window-frame", { style }, [
m("table.window", { onmousedown: focusWindow }, [
m("tbody", [
m("tr.window-header", { onmousedown: grabHeader.bind(vnode) }, [
m(WindowTabs, {
names: vnode.attrs.tabs.map(t => t.name),
activeIndex: vnode.state.activeIndex,
setTab: i => { vnode.state.activeIndex = i; m.redraw() }
}),
m(WindowButtons, { closeWindow })
]),
m("tr", m("td.window-body", { colSpan: 2 }, [
m(tab.component, attr)
]))
])
])
])
}
开发者ID:phincallahan,项目名称:personal-website,代码行数:31,代码来源:Window.ts
示例6: m
view: vnode => {
const { dispatch, getState } = store;
let actionMap = {};
if (typeof actions === 'function') {
actionMap = actions(dispatch, store.getState);
} else if (typeof actions === 'object') {
const actionKeys = Object.keys(actions);
let k;
for (k of actionKeys) {
if (typeof actions[k] === 'function') {
actionMap[k] = dispatchFactory(actions[k], dispatch);
}
}
}
const state = selector(getState());
const attrs = {
...vnode.attrs,
...state,
...actionMap,
dispatch,
}
return m(Component, attrs, vnode.children);
}
开发者ID:phincallahan,项目名称:personal-website,代码行数:25,代码来源:mithril-redux.ts
示例7: comp0
///////////////////////////////////////////////////////////
// 0.
// Simplest component example - no attrs or state.
//
function comp0() {
return {
view() {
return m('span', "Test");
}
};
}
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:11,代码来源:test-factory-component.ts
示例8: m
view: function(ctrl: OnlineRound) {
if (!promoting) return null;
const pieces = ['queen', 'knight', 'rook', 'bishop'];
if (ctrl.data.game.variant.key === 'antichess') pieces.push('king');
return m('div.overlay.open', {
oncreate: helper.ontap(cancel.bind(undefined, ctrl))
}, [m('div#promotion_choice', {
className: settings.general.theme.piece(),
style: { top: (helper.viewportDim().vh - 100) / 2 + 'px' }
}, pieces.map(function(role) {
return m('piece.' + role + '.' + ctrl.data.player.color, {
oncreate: helper.ontap(finish.bind(undefined, ctrl, role))
});
}))]);
}
开发者ID:ornicar,项目名称:lichobile,代码行数:17,代码来源:promotion.ts
示例9: default
export default (): Component<Attrs, {}> => {
const count = 0;
return {
view({attrs}) {
return m('span', `name: ${attrs.name}, count: ${count}`);
}
};
};
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:8,代码来源:test-factory-component.ts
示例10: m
const view = function() {
return m(".container", cells.map(i => {
return m(".slice", {
style: {backgroundPosition: (i % 10 * 11) + "% " + (Math.floor(i / 10) * 11) + "%"},
onbeforeremove: exit
})
}))
}
开发者ID:cronon,项目名称:DefinitelyTyped,代码行数:8,代码来源:test-api.ts
注:本文中的mithril类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论