vue项目修改favicon

首先你的在你的static文件中添加favicon.icon

然后通过以下方式进行修改

1)方式一:修改index.html文件

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

这个方式可能存在的问题是,在你切换路由的时候,favicon可能又会出错,因此建议使用方式二

2)方法二:修改webpack配置文件

build文件夹下面的 webpack.dev.conf.js,webpack.prod.conf.js,修改他们的 HtmlWebpackPlugin 配置对象

new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'index.html',
      inject: true,
      favicon: path.resolve(__dirname, '../static/favicon.ico')
    }),

重启项目工程