我有一个Vue.js应用。对于移动应用程序,我使用Cordova来构建应用程序;对于桌面客户端,我使用Electron来构建它。 在某些情况下,我希望我的应用程序根据是为Cordova还是Electron构建而做出不同的反应。
如果要在Cordova中显示CordovaStartPage
组件,而在Electron中显示ElectronStartPage
,我该如何更改:
export const routerOptions: RouterOptions = {
routes: [
{
path: "/startpage",
component: StartPage
}
]
}
答案 0 :(得分:0)
要检测电子,我只需将调用包装在if检查中:
window && window.process && window.process.type
还有:
process.versions['electron']
希望这会有所帮助。