我当前vue项目中
我当前页面是可以正常访问的,没有问题,如图:
但是,为什么第一个请求请求不到页面
We're sorry but 项目名称 doesn't work properly without JavaScript enabled. Please enable it to continue.
搜索大量资料,有的说把配置nginx,但我这是本地环境
目前问题如图:
我期望效果类似于百度这样 能把页面请求回来
如图:
main.js文件代码
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import axios from "@/axios";
import * as echarts from 'echarts'
import auth from './authentication'
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)
Vue.config.productionTip = false
Vue.prototype.$http = axios
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App),
components:{
App
}
}).$mount('#app')
router.js文件代码
import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../views/login/index'
import desktop from '../components/desktop/index'
import components from '../router/components'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'login',
component: login
}
]
const router = new VueRouter({
routes,
mode: 'hash'
})
router.beforeEach((to,from,next)=>{
if(to.path === '/'){
return next()
}
let token = localStorage.getItem("token");
if (!token){
return next("/")
}
next()
})
export default router