uniapp自定义H5页面浏览器标签栏小图标

  在web页面经常能看到下图的情况,在标签栏中并不是显示的默认的图标,在html和Vue中能很方便的自定义,但是在uniapp中会相对的麻烦
在这里插入图片描述
1. 在项目根目录下创建一个html文件
  这个html文件,将会作为模板引入到H5配置中,并且这个模板也是有要求的,可以参考官方文档(传送门)

<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>
			<%= htmlWebpackPlugin.options.title %>
		</title>
		<!-- Open Graph data -->
		<!-- <meta property="og:title" content="Title Here" /> -->
		<!-- <meta property="og:url" content="http://www.example.com/" /> -->
		<!-- <meta property="og:image" content="http://example.com/image.jpg" /> -->
		<!-- <meta property="og:description" content="Description Here" /> -->
		<script>
			var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports(
				'top: constant(a)'))
			document.write(
				'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
				(coverSupport ? ', viewport-fit=cover' : '') + '" />')
		</script>
		<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
	</head>
	<body>
		<noscript>
			<strong>Please enable JavaScript to continue.</strong>
		</noscript>
		<div id="app"></div>
		<!-- built files will be auto injected -->
	</body>
</html>

2. 将图片复制到项目文件中
  个人建议放在static文件夹下,可以参考我的文件结构
在这里插入图片描述
3. 配置H5模板
  在manifest.json文件中配置index.html模板路径,选择你自己的index文件
在这里插入图片描述
4. 在index.html中引入图片
  在index.html的head根节点中,使用link引入图标

<link rel="icon" href="./static/logo.png"/>

  配置完成后重启项目就可以看到浏览器标签栏的小图标被改变了

猜你喜欢

转载自blog.csdn.net/weixin_45481406/article/details/113897414
今日推荐