当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mithril.trust函数代码示例

本文整理汇总了TypeScript中mithril.trust函数的典型用法代码示例。如果您正苦于以下问题:TypeScript trust函数的具体用法?TypeScript trust怎么用?TypeScript trust使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了trust函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: m

 view: vnode =>
     m("pre.euler-code-wrapper", m.trust(vnode.attrs.code))
开发者ID:phincallahan,项目名称:personal-website,代码行数:2,代码来源:EulerSolution.ts

示例2: trust

import {trust, parseQueryString, buildQueryString} from 'mithril';
import * as h from 'mithril/hyperscript';
import {render} from 'mithril/render';
import {redraw} from 'mithril/redraw';
import * as withAttr from 'mithril/withAttr';

const vnode = trust('Some <strong>bold</strong> text.');

const params = parseQueryString('?id=123');

const qstr = buildQueryString({id: 123});

render(document.body, 'Hello');
render(document.body, h('h1', 'Test'));
render(document.body, [
	h('h1', 'Test'), "abc", null, 123, false, h('p', 'Vnode array'),
	['a', 123, undefined, h('div', 'Nested')]
]);

redraw();

const handler = withAttr("value", (value) => {});
handler({currentTarget: {value: 10}});
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:23,代码来源:test-misc.ts

示例3:

	.then(svg => {
		m.render(document.body, m.trust(svg));
	});
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:3,代码来源:test-api.ts

示例4:

    { name: "contact", link: "mail" },
    { name: "github", link: "https://github.com/phincallahan" },
    { name: "last.fm", link: "https://www.last.fm/user/caphine" },
    { name: "spotify", link: "https://open.spotify.com/user/12141814312" }
]

const node = m.trust(
    `<section id="about">
        <p>
            <b class="name">Phineas Callahan</b> is a math major at 
            <a href="carleton.edu">Carleton College</a>. He enjoys writing clean
            code, solving algorithmic problems, and jamming out to 
            <a href="${discoLink}">disco</a>.
        </p>

        <table class="links">
            <tbody>
                <tr>
                    <td><strong>links: </strong></td>
                    <td><ul>${
    links.map(({ name, link }) => (
        `<li><a href=${link}>${name}</a></li>`
    )).join('')
    }</ul></td>
                </tr>
            </tbody>
        </table>
    </section>`
);

export const About: m.Component = { view: () => node }
开发者ID:phincallahan,项目名称:personal-website,代码行数:31,代码来源:About.ts

示例5: m

// Not intended to be run; only to compile & check types.

import * as m from 'mithril';
import * as stream from 'mithril/stream';

const FRAME_BUDGET = 100;

{
	const vnode = m("div");
	console.assert(vnode.tag === "div");
	console.assert(typeof m.version === "string");
	console.assert(m.version.indexOf(".") > -1);
}

{
	const vnode = m.trust("<br>");
}

{
	const vnode = m.fragment({key: 123}, [m("div")]);
	console.assert((vnode.children as Array<m.Vnode<any, any>>).length === 1);
	console.assert(vnode.children![0].tag === 'div');
}

{
	const handler = m.withAttr("value", (value) => {});
	handler({currentTarget: {value: 10}});
}

{
	const params = m.parseQueryString("?a=1&b=2");
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:test-api.ts


注:本文中的mithril.trust函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。