cordova - How do I switch which Vue component I display in my app depending on whether it's build in Cordova or Electron?
问题描述
I have a Vue.js app. For mobile apps I build the app with Cordova and for Desktop clients I build it with Electron. In some cases I want my application to react differently depending on whether it's build for Cordova or Electron.
If I want to show the CordovaStartPage
-component with Cordova and ElectronStartPage
with Electron, how do I have to change:
export const routerOptions: RouterOptions = {
routes: [
{
path: "/startpage",
component: StartPage
}
]
}
解决方案
要检测电子,我只需将调用包装在 if 检查中:
window && window.process && window.process.type
还有:
process.versions['electron']
希望这可以帮助。
推荐阅读
- dart - 使用 Future.delayed 时的测试中断
- circuit-breaker - 在检查函数中注册失败尝试似乎被计算为双倍
- php - 如何从数据库中获取特定列
- excel - 为行创建键/唯一值
- hyperledger-fabric - 将现有的 Hyperledger Fabric 排序器从单独升级到基于 Kafka
- angular - 没有装饰器的组件的角度依赖注入
- sql - SQL - 想要为每个 IF 条件写入唯一的错误值
- oozie - oozie 4.2.0 版本中的重试最大值
- file - 接受“作为 .BAT 文件中用户的输入?
- java - 从JDK1.8升级到JDK1.11时如何解决“无法解析导入javax.xml.namespace.QName”