替换uni-app中H5的默认图标

在使用uni-app开发前端,发布为H5形式的时候,浏览器标题的左上角会有Vue默认的标志,如下图所示,我们希望把它替换成需要的新图标。
Gitee参考代码
在这里插入图片描述
首先把要修改的图标文件放在static目录下,并重命名为favicon.ico,然后在根目录下新建template.html文件,粘贴以下代码到template.html

<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <title>
            <%= htmlWebpackPlugin.options.title %>
        </title>
        <script>
            document.addEventListener('DOMContentLoaded', function() {
                document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
            })
        </script>
        <link rel="stylesheet" href="<%= BASE_URL %>./static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
		<link rel="icon" type="image/png" sizes="32x32" href="./static/favicon.ico">
    </head>
    <body>
        <noscript>
            <strong>Please enable JavaScript to continue.</strong>
        </noscript>
        <div id="app"></div>
        <!-- built files will be auto injected -->
    </body>
</html>

双击manifest.json打开配置菜单,切换到H5配置,在index.html模版路径中填入template.html,保存所有修改。
在这里插入图片描述
调试运行,显示结果如下,默认图标修改成功!
在这里插入图片描述

参考资料

[1] https://www.cnblogs.com/wbl001/p/12330792.html
[2] https://www.cnblogs.com/niceyoo/p/12215860.html

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值