本文整理匯總了TypeScript中mithril.route函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript route函數的具體用法?TypeScript route怎麽用?TypeScript route使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了route函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: initializeRouter
export function initializeRouter() {
route.prefix('');
const container = document.querySelector('#container');
route(container, '/', {
'/': { onmatch: getRooms, render: HomePage }
});
}
示例2:
pubsub.on('connected', connection => {
document.body.className =
'theme--' + (connection.settings().theme || 'dark-orange')
connected = true
document.title =
'Gandalf - connected to ' + connection.settings().name
m.route('/sql/' + connection.settings().name)
})
示例3: default
},
"Click me"
)
];
}
};
}
///////////////////////////////////////////////////////////
//
// Test that all are mountable components
//
m.route(document.body, '/', {
'/comp0': comp0,
'/comp1': comp1,
'/comp2': comp2,
'/comp3': comp3,
'/comp4': comp4,
'/comp5': comp5
});
///////////////////////////////////////////////////////////
//
// Concise module example with default export
//
interface Attrs {
name: string;
}
export default (): Component<Attrs, {}> => {
const count = 0;
return {
示例4: pagify
for (const page of adminPages) {
if (window.authorizer.hasAccess(page, 2)) {
m.route.set(`/admin/${page}`);
return null;
}
}
return null;
}
};
return component;
}
m.route(document.body, "/overview", {
"/login": pagify("login", loginPage),
"/overview": pagify("overview", overviewPage),
"/devices": pagify("devices", devicesPage),
"/devices/:id": pagify("devices", devicePage),
"/faults": pagify("faults", faultsPage),
"/admin": redirectAdminPage(),
"/admin/presets": pagify("presets", presetsPage),
"/admin/provisions": pagify("provisions", provisionsPage),
"/admin/virtualParameters": pagify(
"virtualParameters",
virtualParametersPage
),
"/admin/files": pagify("files", filesPage),
"/admin/config": pagify("config", configPage),
"/admin/users": pagify("users", usersPage),
"/admin/permissions": pagify("permissions", permissionsPage)
});
示例5: createSplitter
.then(settings => {
const splitter = createSplitter(m)
const pubsub = new EventEmitter()
createGlobalShortcuts(pubsub)
createCommitControl(pubsub)
const errorHandler = createErrorHandler(m)
const loginModule = createLoginModule(m, pubsub, connect, settings)
const actions = createActions(m, pubsub, createPopupmenu)
const tableSearch = createTableSearch(m, pubsub, createPopupmenu)
const statusbar = createStatusbar(m, pubsub)
const editor = createEditor(m, pubsub, CodeMirror)
const result = createResult(m, pubsub)
const editConnection = createEditConnection(m, pubsub, settings)
const bookmarkModule = createBookmarkModel(
m,
fs,
pubsub,
editor,
createPopupmenu
)
const historyModule = createHistoryView(
m,
pubsub,
createPopupmenu,
getHistoryModel
)
const columnsPrompt = createColumnsPrompt(
m,
editor,
getTables,
pubsub,
createPopupmenu
)
let connected = false
window.addEventListener(
'beforeunload',
() => {
pubsub.emit('disconnect')
},
false
)
createExecuter(pubsub, editor, m)
createSchemaHandler(fs, pubsub)
createSqlHint(pubsub, editor, getTables, CodeMirror)
pubsub.on('new-window', () => {
console.log('emit new-window')
ipcRenderer.send('new-window')
})
pubsub.on('connected', connection => {
document.body.className =
'theme--' + (connection.settings().theme || 'dark-orange')
connected = true
document.title =
'Gandalf - connected to ' + connection.settings().name
m.route('/sql/' + connection.settings().name)
})
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')
}
}
}
const sqlModule = {
controller: Controller,
view() {
return [
loginModule.view(),
editor.view(),
splitter(),
result.view(),
statusbar.view(),
actions.view(),
tableSearch.view(),
bookmarkModule.view(),
historyModule.view(),
columnsPrompt.view(),
errorHandler.view(),
editConnection.view(),
]
},
//.........這裏部分代碼省略.........
示例6: m
const root = window.document.createElement("div");
m.render(root, m("div"));
console.assert(root.childNodes.length === 1);
}
{
const root = window.document.createElement("div");
m.mount(root, { view: () => m("div") });
console.assert(root.childNodes.length === 1);
console.assert(root.firstChild!.nodeName === "DIV");
}
{
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") }
});
示例7: BudgetContext
m.startComputation();
context.loadData(data);
m.endComputation();
});
} else {
let storedBudgetData = localStorage.getItem(budgetDataKey) || "";
context = new BudgetContext(storedBudgetData);
}
let menu = new Menu.MenuComponent([
new Menu.BasicMenuItem(new RegExp("expenses"), `/expenses/${DF.formatDateForUrl(moment())}`, "Expenses"),
new Menu.BasicMenuItem(new RegExp("rates"), `/rates/${DF.formatDateForUrl(moment())}`, "Rates"),
new Menu.DropdownMenuItem(new RegExp("summary"), "Summary",
[
new Menu.BasicMenuItem(new RegExp("weekly"), `/summary/${DF.formatDateForUrl(moment())}/weekly`, "Weekly"),
new Menu.BasicMenuItem(new RegExp("categories"), `/summary/${DF.formatDateForUrl(moment())}/categories`, "By Category"),
])
]);
let pageModel = new PageModel(root, context, fileDialog, fileNameKey, storedFileName);
let page = Page.bind(null, pageModel, menu);
m.route.mode = "search";
m.route(root, `/expenses/${DF.formatDateForUrl(moment())}`, {
"/rates/:date": new page(new RatesComponent(context)),
"/expenses/:date": new page(new ExpenseComponent(context)),
"/summary/:date/:type": new page(new SummaryComponent(context)),
"/categories": new page(new CategoryComponent(context))
});