如何更改vue项目窗口的标题title和图标icon

Vue CLI创建的项目窗口的标题默认是打包后的项目名称,默认图标是Vue的图标favicon.ico。

<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>

解决方法:

修改图标:直接将新图标导入public文件夹,然后将favicon.ico替换为新图标的名字即可,此处可以不用ico文件,但是为了规范,还是将图片转为ico文件更好

<link rel="icon" href="<%= BASE_URL %>darcy.ico">

修改标题:

  •  一:若项目名称需修改为“darcy练手项目”,那么直接在<title>标签中填入项目名称即可。

<title><darcy练手项目</title>

二:修改vue.config.js文件        

module.exports = {
 pages: {
    index: {
      template: 'public/index.html',
      entry: 'src/main.ts',
      filename: 'index.html',
      title:'darcy练手项目',
    }
  }
}

猜你喜欢

转载自blog.csdn.net/weixin_43923808/article/details/131803586