Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

vue-router history mode

使用Vue-router history模式,为什么npm run dev通过express创建的虚拟服务器可以访问,但是打包之后再本地访问不了,并且,所有需要加载的文件都加载出来了的!
代码和截图如下:
使用的是vue-cli webpack
代码结构:

clipboard.png

router/index.js
import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import Aaa from '@/components/Aaa'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Hello',
      component: Hello
    },
    {
      path: '/Aaa.html',
      component: Aaa
    }
  ],
  mode:'history'
})

npm run dev 后

clipboard.png
webpack打包之后通过本地服务器环境打开的情景:

clipboard.png
所有的JS文件和Css文件以及Hmtl都加载出来了,可就是页面显示不出来,求大神帮帮忙!!!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

如果使用history mode的话,线上代码的运行是需要服务器提供支持的
具体配置参考 https://router.vuejs.org/zh-c...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...