
Vue
景行景止丷
浮生。与清风皓月。久已忘形。
展开
-
Vue - 部署到nginx
1、config/index.js 中,找到 build 里的 assetsPublicPath,确认或修改其内容为 ‘/’ ,这样生成的 index.html 中资源是从 /static/xxx 里开始找的。assetsPublicPath: '/'2、修改路由为history模式,可以去掉路由路径里的#。在 router/index.js 中 Router配置的第一行添加:mode: 'history'3、修改 nginx 的配置文件,将项目打包生成的dist文件夹放到 /home/项目名原创 2021-03-06 23:41:39 · 456 阅读 · 0 评论 -
Vue - 去掉路由中的#号
vue-router默认是hash模式,在hash模式下,是会有#号在URL上,可以在路由的第一行添加 mode:history来去掉#号。const router = new Router({ mode: 'history', routes: []})原创 2021-03-06 17:31:58 · 4964 阅读 · 0 评论 -
Vue - 媒体查询无效
踩坑实录:自己用了内联样式,而内联样式具有最高优先级,导致自己的媒体查询无效,解决办法就是把内联样式改为页级,并且放到媒体查询的前面。原创 2021-03-06 14:17:22 · 960 阅读 · 0 评论 -
Vue - 设置每个页面的title
可以直接在 router/index.js 中设置:const router = new Router({ routes: [ { path: '/index', component: Home, name: '首页', meta: { title: '首页' } } ]})// 设置titlerouter.afterEach((to, from) => { window.document原创 2021-03-05 19:57:37 · 291 阅读 · 0 评论