vue-cli学习-Node静态服务器
配置服务器
采用 hash 模式进行打包,然后通过 Node 静态服务器运行测试
const router = new VueRouter({
mode: 'hash', //默认mode:'hash'
routes
})
打包后,想要在静态服务器上测试,先要安装静态服务器
npm i serve -g //安装
serve dist //运行 dist 目录
把模式改为:history 模式,再执行服务器
mode: 'history',
serve dis
PS: 在点击方式下,貌似看不出问题,当刷新页面或从地址栏改变 id,则 404
为了解决这个问题,命令提供了一个-s 的参数,解决这个问题
serve dist -s

浙公网安备 33010602011771号