當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mithril類代碼示例

本文整理匯總了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;未經允許,請勿轉載。