本文整理汇总了TypeScript中riot.mount函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mount函数的具体用法?TypeScript mount怎么用?TypeScript mount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mount函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
// util.tmpl
riot.util.tmpl.errorHandler = (err: riot.TemplateError) => {
console.error(err.message + ' in ' + err.riotData.tagName);
};
// util.vdom
console.log(riot.util.vdom[0].isMounted);
const mockOpts = {
foo: true,
bar: 1,
baz: [1, '2', [3]]
};
const tag = riot.mount('test')[0];
// Mounting
// mount all custom tags with a class name .customer
const tags: riot.TagInstance[] = riot.mount('.customer');
console.log(tags.length);
// mount <account> tag and pass an object as options
riot.mount('account', mockOpts);
// mounts custom tag "my-tag" to div#main with some options
riot.mount('div#main', 'my-tag', mockOpts);
// mounts "users" tag to #slide node and some options
riot.mount(document.getElementById('slide') as Element, 'users', mockOpts);
// unregister the tag
riot.unregister('test-tag');
// Rendering
示例2: async
const mountPage = async (page: string, opts: object = {}) => {
await import(`./pages/${page}`)
mount(mountPoint, page, opts)
}