默认cli生成的项目中,url是使用带锚点的方式跳转,即url中包含#,如果想去除#,则要在router中的index.js文件中添加mode: 'history'
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'Hello',
component: Hello
}
]
})
使用npm run build 可以将src中的源码编译压缩成dist中的编译后的文件,编译压缩的一些配置文件都在/config/index.js文件中
assetsSubDirectory:
'static',
assetsPublicPath:
'/',
(遇到的坑1:assetsPublicPath属性修改为'./',则会导致在子页面时刷新页面引用的js与css文件多了前缀导致引用失败)