vue webpack loading chunk xx failed.该如何解决?

进网站后没有报错,数据也请求成功,但是只要点其他的链接就出现如下报错!
图片描述

相关:
"vue": "^2.5.2",
"vue-resource": "^1.3.5",
"vue-router": "^3.0.1",
"webpack": "^3.6.0",

router.index主要代码

import Vue from 'vue'
import Router from 'vue-router'

const index = () => import('@/components/front/index')
const Home = () => import('@/components/front/Home')
const article = () => import('@/components/front/article')
const SearchResult = () => import('@/components/front/SearchResult')
const Articles = () => import('@/components/front/Articles')
const login = () => import('@/components/back/login')
const admin = () => import('@/components/back/admin')
const posts = () => import('@/components/back/posts')
const editor = () => import('@/components/back/editor')
const drafts = () => import('@/components/back/drafts')
const search = () => import('@/components/back/search')
const account = () => import('@/components/back/account')

const router = new Router({
    mode: 'history',
    scrollBehavior(to, from, savedPosition) {
        if (to.hash) {
            return {
                selector: to.hash
            }
        } else {
            return {x: 0, y: 0}
        }
    },
    routes: [
        {
            path:'/',
            redirect:'home',
            component: index,
            children: [
                {path: 'home', name: 'home', component: Home, meta: {title: '博客首页'}},
                {path: 'articles', name: 'articles', component: Articles, meta: {title: '学习笔记分享'}},
                {path: 'articles/:id', name: 'article', component: article},
                {path: 'search/:text', name: 'SearchResult', component: SearchResult, meta: {title: '搜索结果'}}
            ]
        },
        {
            path: '/login',
            name: 'login',
            component: login,
            meta: {title: '登录页面'}
        },
        {
            path:'/admin',
            redirect:'admin/posts',
            component: admin,
            children: [
                {path:'posts',name:'posts', component: posts, meta:{requireAuth:true, title:'博客文章'}},
                {path:'editor',name:'editor', component: editor, meta:{requireAuth:true, title:'博客编辑'}},
                {path:'drafts',name:'drafts', component: drafts, meta:{requireAuth:true, title:'博客草稿'}},
                {path: 'search', name: 'search', component: search, meta: {requireAuth: true, title: '搜索结果'}},
                {path: 'account', name: 'account', component: account, meta: {requireAuth: true, title: '修改账户'}}
            ]
        }
    ],
})

export default router

项目运行在本地是没问题的,打包丢到服务器就出这个问题,请问可能是哪里配置有问题?怎么解决..


JS请求不成功的报错:那个字体先不管, 这个1.296c763ff4e540ac2581.js 文件不知道哪来的~~我在打包后的/statuc/js里没找到这个文件
图片描述

阅读 8.2k
3 个回答

弄好了... 修改了下nginx配置图片描述

因为在nginx配置的根目录/var/www/html下面压根就没有loading这个真实目录存在,这些访问资源都是在js里渲染的。在nginx配置里添加vue-route的跳转设置,就ok了。虽然没完全懂为什么,但确实有效~
原文链接:https://www.cnblogs.com/kevin...

看你上面,js没有加载成功

1.确认一下你的文件目录下有没有这个文件
2.确认一下这个文件的读写权限是啥

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏