本文整理匯總了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)
}