本文整理汇总了TypeScript中mithril.route类的典型用法代码示例。如果您正苦于以下问题:TypeScript route类的具体用法?TypeScript route怎么用?TypeScript route使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了route类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: resolve
.catch(err => {
if (!window.username && err.message.indexOf("authorized") >= 0) {
notifications.push("error", err.message);
m.route.set("/login", { continue: requestedPath });
}
state = { error: err.message };
resolve();
});
示例2: initializeRouter
export function initializeRouter() {
route.prefix('');
const container = document.querySelector('#container');
route(container, '/', {
'/': { onmatch: getRooms, render: HomePage }
});
}
示例3:
onmatch: () => {
for (const page of adminPages) {
if (window.authorizer.hasAccess(page, 2)) {
m.route.set(`/admin/${page}`);
return null;
}
}
return null;
}
示例4: Controller
function Controller() {
const connName = m.route.param('conn')
if (!connected && connName) {
const connSettings = settings.connections.find(
c => c.name === connName
)
if (connSettings && connSettings.host === 'hsql:inmemory') {
console.log('reconnect to hsql:inmemory!!')
connect(
{ host: connSettings.host },
connSettings
).then(connection => {
pubsub.emit('connected', connection)
})
} else {
pubsub.emit('login')
}
}
}
示例5: m
view: () => {
if (window.username) {
return m(
"div.user-menu",
window.username,
m(
"button",
{
onclick: e => {
e.target.disabled = true;
store
.logOut()
.then(() => {
location.hash = "";
location.reload();
})
.catch(err => {
e.target.disabled = false;
notifications.push("error", err.message);
});
return false;
}
},
"Log out"
)
);
} else {
return m(
"div.user-menu",
m(
"a",
{
href:
"#!/login?" + m.buildQueryString({ continue: m.route.get() })
},
"Log in"
)
);
}
}
示例6: setTimeout
setTimeout(() => {
console.assert(m.route.get() === "/b");
}, FRAME_BUDGET);
示例7: m
{
const root = window.document.createElement("div");
m.route(root, "/a", {
"/a": { view: () => m("div") }
});
setTimeout(() => {
console.assert(root.childNodes.length === 1);
console.assert(root.firstChild!.nodeName === "DIV");
}, FRAME_BUDGET);
}
{
const root = window.document.createElement("div");
m.route.prefix("#");
m.route(root, "/a", {
"/a": { view: () => m("div") }
});
setTimeout(() => {
console.assert(root.childNodes.length === 1);
console.assert(root.firstChild!.nodeName === "DIV");
}, FRAME_BUDGET);
}
{
const root = window.document.createElement("div");
m.route(root, "/a", {
"/a": { view: () => m("div") }
});