Electron-vue 创建新 window
Electron-vue creating new window
我正在尝试使用以下代码创建新的 window:
createBotWindow() {
const winUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/bot` : `file://${__dirname}/index.html`;
this.availableWindows[1] = new BrowserWindow({
x: -8, //to be exacly x:0 in windows...
y: 0,
height: 500,
width: 500,
useContentSize: true,
show: false
});
this.availableWindows[1].loadURL(winUrl);
this.availableWindows[1].on('closed', () => {
this.availableWindows[1] = null;
});
},
我有vue路由器
{
path: '/bot',
name: 'bot-page',
component: require('@/components/BotPage').default
},
在组件目录中我有 BotPage.vue 文件:
<template>
<h2>Hello World</h2>
</template>
<script>
export default {}
</script>
在控制台的新 window 中有 2 个错误:
Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-hY0Tz9CeWmB42Cjr7IVuwuBk5B6PQB2D/+LGDs8jrZY='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
Failed to load resource: the server responded with a status of 404 (Not Found)
并且在新 window 中不显示 Hello World。
我做错了什么?
我不得不在 vue 路由器中禁用 mode: 'history'
并加载此 url:http://localhost:9080/#/bot
.
我正在尝试使用以下代码创建新的 window:
createBotWindow() {
const winUrl = process.env.NODE_ENV === 'development' ? `http://localhost:9080/bot` : `file://${__dirname}/index.html`;
this.availableWindows[1] = new BrowserWindow({
x: -8, //to be exacly x:0 in windows...
y: 0,
height: 500,
width: 500,
useContentSize: true,
show: false
});
this.availableWindows[1].loadURL(winUrl);
this.availableWindows[1].on('closed', () => {
this.availableWindows[1] = null;
});
},
我有vue路由器
{
path: '/bot',
name: 'bot-page',
component: require('@/components/BotPage').default
},
在组件目录中我有 BotPage.vue 文件:
<template>
<h2>Hello World</h2>
</template>
<script>
export default {}
</script>
在控制台的新 window 中有 2 个错误:
Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-hY0Tz9CeWmB42Cjr7IVuwuBk5B6PQB2D/+LGDs8jrZY='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
Failed to load resource: the server responded with a status of 404 (Not Found)
并且在新 window 中不显示 Hello World。
我做错了什么?
我不得不在 vue 路由器中禁用 mode: 'history'
并加载此 url:http://localhost:9080/#/bot
.