VUE Router not working with two Electron BrowserWindows

丶灬走出姿态 提交于 2019-12-25 01:34:52

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/43813786/vue-router-not-working-with-two-electron-browserwindows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!