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