VUE路由器无法与两个Electron BrowserWindows一起使用 [英] VUE Router not working with two Electron BrowserWindows

查看:662
本文介绍了VUE路由器无法与两个Electron BrowserWindows一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用具有vue-router的同一Vue应用程序使用两个BrowserWindows创建一个应用程序,但是该路由器无法正常工作。我总是在第二条路线上收到错误无法获取/。



main\index.js

  var mainURL =`http:// localhost:9080 /`
var secondURL =`http:// localhost:9080 / page2`

函数createWindow(){
mainWindow = new BrowserWindow({
高度:600,
宽度:800
})
mainWindow.loadURL (mainURL)
mainWindow.on('closed',()=> {
mainWindow = null
})

secondWindow = new BrowserWindow({
高度:600,
宽度:800
})
secondWindow.loadURL(secondURL)
secondWindow.on('closed',()=> {
secondWindow = null
})
}

app.on('ready',createWindow)

routes.js

 导出默认值[
{
路径: /,
名称:着陆页,
组件:require('components / LandingPageView')
},
{
路径:'/ page2',
名称:'landing-page2',
组件:require('components / LandingPageView2')
},
{
路径:' *',
重定向:'/'
}
]

测试代码:即可完成这项工作。


I’m trying to create an app with two BrowserWindows using the same Vue App with vue-router, but the router aren’t working. I’m always receiving error ‘Cannot GET /’ for the second route.

main\index.js

var mainURL = `http://localhost:9080/`
var secondURL = `http://localhost:9080/page2`

function createWindow () {
  mainWindow = new BrowserWindow({
    height: 600,
    width: 800
  })
  mainWindow.loadURL(mainURL)
  mainWindow.on('closed', () => {
    mainWindow = null
  })

  secondWindow = new BrowserWindow({
    height: 600,
    width: 800
  })
  secondWindow.loadURL(secondURL)
  secondWindow.on('closed', () => {
    secondWindow = null
  })
}

app.on('ready', createWindow)

routes.js

export default [
  {
    path: '/',
    name: 'landing-page',
    component: require('components/LandingPageView')
  },
  {
    path: '/page2',
    name: 'landing-page2',
    component: require('components/LandingPageView2')
  },
  {
    path: '*',
    redirect: '/'
  }
]

Testing code: https://github.com/melquic/vue-two-windows.git

Error print screen:

Thank you for help! Best.

解决方案

The URL needs to be http://localhost:9080/#/page2 in order to make this work.

这篇关于VUE路由器无法与两个Electron BrowserWindows一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆