use*_*181 3 service-worker progressive-web-apps nuxt.js
我正在尝试使用该nuxt generate命令生成一个 nuxt 应用程序。我想通过打开index.html文件dist夹中的文件来使用它。除了我加载一些静态资产的一页外,一切正常。我收到以下错误:
DOMException: 无法构造 'Worker': 'file:///Users/web-app/dist/_nuxt/a694c9435aa306bfdc85.worker.js' 处的脚本无法从原点 'null' 访问。在新的 e.exports (file:///Users/web-app/dist/_nuxt/ddebbd7698f3519f1f2a.js:2:387818) 在 Object.253 (file:///Users/web-app/dist/_nuxt/ddebbd7698f3519f1f1f1f3519f1f2a.js:2:387818) .js:2:41913) 在 c (file:///Users/web-app/dist/_nuxt/849a5edcbb351f009715.js:1:534) 在 Module.318 (file:///Users/web-app/dist /_nuxt/58dff71a539121ee82b0.js:1:7082) 在 c (file:///Users/web-app/dist/_nuxt/849a5edcbb351f009715.js:1:534)
这是我的nuxt.config.js文件:
export default {
mode: 'spa',
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
'~/assets/css/tailwind.css',
'~/assets/css/all.css'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/proxy',
'@nuxtjs/toast'
],
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {
},
/*
** Build configuration
*/
build: {
postcss: {
plugins: {
tailwindcss: './tailwind.config.js'
}
},
/*
** You can extend webpack config here
*/
extend(config, { isDev, isClient }) {
if (!isDev) {
// relative links, please.
config.output.publicPath = "./_nuxt/";
}
return config;
}
},
router: {
mode: "hash"
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有任何方法可以禁用我的应用程序中的服务人员。
您可以禁用的workbox子模块nuxt.config.js。
modules: [
['@nuxtjs/pwa', { workbox: false }],
],
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3083 次 |
| 最近记录: |