本文整理匯總了TypeScript中@dojo/framework/widget-core/vdom.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Registry
import renderer from '@dojo/framework/widget-core/vdom';
import { w } from '@dojo/framework/widget-core/d';
import { registerRouterInjector } from '@dojo/framework/routing/RouterInjector';
import TodoApp from './widgets/TodoApp';
import Registry from '@dojo/framework/widget-core/Registry';
const registry = new Registry();
const router = registerRouterInjector([
{
path: 'filter/{filter}',
outlet: 'filter',
defaultParams: { filter: 'all' },
defaultRoute: true
}
], registry);
const r = renderer(() => w(TodoApp, {}));
r.mount({ registry });
示例2: router
add("build-time-render", false);
}
const registry = new Registry();
let context: Context;
registry.defineInjector('state', (invalidator) => {
context = new Context(invalidator);
return () => context;
});
function router() {
const [, route = 'top', id = '1'] = window.location.hash.split('/');
if (route === 'user') {
context.route = 'user';
} else if (route === 'comments') {
if (id !== context.itemId || context.route !== 'comments') {
context.fetchItem(id);
}
} else {
if (route !== context.category || parseInt(id, 10) !== context.page || context.route !== 'content') {
context.fetchStories(route, parseInt(id, 10));
}
}
}
window.onhashchange = router;
router();
const r = renderer(() => w(AppContainer, {}));
r.mount({ domNode: document.getElementById('app') as HTMLElement, registry });
示例3: renderer
import renderer from '@dojo/framework/widget-core/vdom';
import { w } from '@dojo/framework/widget-core/d';
import App from './widgets/App';
const r = renderer(() => w(App, {}));
r.mount();
示例4: _onSelected
import { WidgetBase } from '@dojo/framework/widget-core/WidgetBase';
import { w } from '@dojo/framework/widget-core/d';
import renderer from '@dojo/framework/widget-core/vdom';
import { Menu } from './widgets/Menu';
import { MenuItem } from './widgets/MenuItem';
class Example extends WidgetBase {
private _onSelected(data: any) {
console.log(data);
}
protected render() {
return w(Menu, { onSelected: this._onSelected }, [
w(MenuItem, { key: 'a', title: 'Menu Item A' }),
w(MenuItem, { key: 'b', title: 'Menu Item B', selected: true }),
w(MenuItem, { key: 'c', title: 'Menu Item C' })
]);
}
}
const element = document.getElementById('widget') as HTMLElement;
const r = renderer(() => w(Example, {}));
r.mount({ domNode: element });
示例5: _onThemechange
import '@dojo/themes/dojo/index.css';
const themes: { [index: string]: any } = {
dojo,
vanilla: undefined
};
const registry = new Registry();
const themeContext = registerThemeInjector(dojo, registry);
registry.defineInjector('theme-context', () => {
return () => ({
get: () => themeContext,
set: (theme: string) => themeContext.set(theme)
});
});
let initialAppState = {
registry,
themes: Object.keys(themes),
onThemeChange: _onThemechange
}
function _onThemechange(theme: string) {
themeContext.set(themes[theme]);
}
const r = renderer(() => w(App, initialAppState));
r.mount({ registry });