vue-router无法解析异步组件默认值:ChunkLoadError:加载块供应商〜演示失败

时间:2020-04-20 08:13:36

标签: vue.js webpack vue-router

我用LaravelVuejs编写了程序,在localhost上运行良好,但在host上却出错。

问题:

程序在本地主机上运行良好,但是当我将其放在主机上时,出现以下错误:

[vue-router]无法解决异步组件默认设置: ChunkLoadError:加载块供应商〜演示失败

ChunkLoadError: "Loading chunk vendors~demo failed.
(missing: http://example.com/vendors~demo.js)"
    requireEnsure http://example.com/js/manifest.js:127
    component webpack-internal:///./resources/js/router.js:56
    resolveAsyncComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1904
    flatMapComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1931
    flatMapComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1931
    flatMapComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1930
    resolveAsyncComponents webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1866
    iterator webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2121
    step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1847
    step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1851
    step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1851
    step webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1848
    iterator webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2140
    _callee$ webpack-internal:///./resources/js/permission.js:109

我做什么:

  • 我认为文件可能没有正确放置在主机上,但这不是问题。
  • 下一个可能性是更新Webpack,但这并不能解决问题。

问题出在哪里?

1 个答案:

答案 0 :(得分:2)

我使用以下命令来获取已编译的js文件,这是一个错误。 这些对于开发目的很有帮助

npm run watch 

yarn watch

使用以下命令获取输出,这样您就不会遇到像我这样的问题。

npm run prod