进网站后没有报错,数据也请求成功,但是只要点其他的链接就出现如下报错!
相关:
"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里没找到这个文件
弄好了... 修改了下nginx配置
因为在nginx配置的根目录/var/www/html下面压根就没有loading这个真实目录存在,这些访问资源都是在js里渲染的。在nginx配置里添加vue-route的跳转设置,就ok了。虽然没完全懂为什么,但确实有效~
原文链接:https://www.cnblogs.com/kevin...