一、普通 HTML 页面,配置图标和文字
<head> <title>标题栏文字</title> <link rel="icon" href="../favicon.ico" type="image/x-icon"> </head>
二、vue 项目中,配置图标和文字
1. 在网站根目录下的 index.html 文件的title 标签中添加标题栏文字
2. 将图片.ico 文件放在网站根目录下
3. 修改 build 文件夹下 webpack.prod.conf.js 和 webpack.dev.conf.js 文件
var path = require('path') // 开头引入 path 模块 .... // HtmlWebpackPlugin 中添加 favicon new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', favicon: path.resolve('favicon.ico'), // 引入图片地址 inject: true })
4. 重新启动项目即可