當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mithril.route函數代碼示例

本文整理匯總了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 }
  });
}
開發者ID:vdsabev,項目名稱:betahaus-sofia-office-manager,代碼行數:8,代碼來源:router.ts

示例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)
        })
開發者ID:jakobrun,項目名稱:gandalf,代碼行數:9,代碼來源:main.ts

示例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 {
開發者ID:DenisCarriere,項目名稱:DefinitelyTyped,代碼行數:32,代碼來源:test-factory-component.ts

示例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)
});
開發者ID:zaidka,項目名稱:genieacs,代碼行數:30,代碼來源:app.ts

示例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(),
                ]
            },
//.........這裏部分代碼省略.........
開發者ID:jakobrun,項目名稱:gandalf,代碼行數:101,代碼來源:main.ts

示例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") }
	});
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:test-api.ts

示例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))
});
開發者ID:AlexanderLindsay,項目名稱:dailybudgeteer,代碼行數:31,代碼來源:start.ts


注:本文中的mithril.route函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。