本文整理汇总了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>
示例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")
])
])
}
示例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);
});
示例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...");
}
}
示例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)
]))
])
])
])
}
示例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);
}
示例7: comp0
///////////////////////////////////////////////////////////
// 0.
// Simplest component example - no attrs or state.
//
function comp0() {
return {
view() {
return m('span', "Test");
}
};
}
示例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))
});
}))]);
}
示例9: default
export default (): Component<Attrs, {}> => {
const count = 0;
return {
view({attrs}) {
return m('span', `name: ${attrs.name}, count: ${count}`);
}
};
};
示例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
})
}))
}