1,普通 HTML 页面,配置图标及文字
<head>
<title>标题栏文字</title>
<link rel="icon" href="../favicon.ico" type="image/x-icon">
</head>
2,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,重新启动项目即可
本文介绍如何在HTML页面和Vue项目中配置网页图标与标题栏文字。对于HTML页面,通过<link>标签设置图标路径;对于Vue项目,需在index.html中设置标题,并放置.ico图标文件,同时修改webpack配置文件引入图片。
4356

被折叠的 条评论
为什么被折叠?



