vue 项目的初始化,打包的坑

1、打包之后展示空白页以及自提图标的问题

config index.js

assetsPublicPath加一个./,设置同级位置。

untils.js 中vue-style-loader 加一个publicPath:'../../',因为打包的路劲问题

2.vue设置浏览器标签title和icon

<link rel="shortcut icon" type="image/x-icon" href="./static/data/favicon.ico">

一定要ico的图标不然没用

title:

(1)每个页面都加上

  mounted() {
    //测试
    document.title = "Holle World";
  }

(2)还有设置路由

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/views/HelloWorld'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld,
      meta:{
        title:'你好,世界!'
      }
    }
  ]
})

以及main.js中添加路由过滤

router.beforeEach((to, form, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  }
  next();
})

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值