【问题标题】:Electron vue new window with child route带有子路由的电子 vue 新窗口
【发布时间】:2020-02-24 03:05:24
【问题描述】:

在电子 vue 中,我想为每个新窗口创建新的 vue 实例。这工作正常,直到我想将路由器子组件加载到新窗口。例如我有条目

add: path.join(__dirname, '../src/renderer/pages/add.js'),

然后在 pages/add.js 中,我正在使用此类路由器路由创建新的 vue 实例:

routes: [
    {
        path: '/',
        name: 'add',
        component: require('@/components/add/add').default,
        beforeEnter: (to, from, next) => guard(to, from, next),
        children: [
            {
                path: 'exp',
                component: require('@/components/add/exp').default,
                beforeEnter: (to, from, next) => guard(to, from, next)
            },

如果我只想加载 / 它可以正常工作,但我的 add.vue 组件是

<template>
    <router-view></router-view>
</template>

当我启动假设加载 add.html 的新窗口时,我希望它从一开始就加载子路由:

createAddExpPlaceWindow() {
    const winUrl = process.env.NODE_ENV === 'development'
        ? `http://localhost:9080/#/add/exp`
        : `file://${__dirname}/add.html/!#/exp`;

这条路径file://${__dirname}/add.html/!#/exp 不正确,因为我看到了空白窗口。我也试过file://${__dirname}/add.html/expfile://${__dirname}/add.html/#/exp 他们似乎都没有工作。

【问题讨论】:

    标签: vue.js electron router


    【解决方案1】:

    作为临时修复,我只是将路径更改为 file://${__dirname}/add.html/exp?opt=exp 并基于 add.vue 创建的钩子中的 window.location.search 我正在通过 router.push({ path: 'exp' }) 推送路线。

    【讨论】:

      猜你喜欢
      • 2020-06-15
      • 1970-01-01
      • 1970-01-01
      • 2021-02-08
      • 2018-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多