我正在尝试使用以下代码创建新窗口:
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
},
在 components 目录中我有 BotPage.vue 文件:
<template>
<h2>Hello World</h2>
</template>
<script>
export default {}
</script>
在控制台的新窗口中有 2 个错误:
拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“default-src 'self'”。启用内联执行需要“unsafe-inline”关键字、哈希(“sha256-hY0Tz9CeWmB42Cjr7IVuwuBk5B6PQB2D/+LGDs8jrZY=”)或随机数(“nonce-...”)。另请注意,'script-src' 未明确设置,因此 'default-src' 用作后备。
加载资源失败:服务器响应状态为 404(未找到)
并且它不会在新窗口中显示 Hello World。
我做错了什么?