当前位置:   article > 正文

UNIAPP_顶部导航栏右侧添加uni-icons图标,并绑定点击事件,自定义导航栏右侧图标_uniapp顶部页面右侧添加一个icon

uniapp顶部页面右侧添加一个icon

效果
在这里插入图片描述

1、导入插件
uni-icons插件:https://ext.dcloud.net.cn/plugin?name=uni-icons

复制 uniicons.ttf 文件到 static/fonts/ 下
仅需要那个uniicons.ttf文件,不引入插件、单独把那个文件下载到本地也是可以的
在这里插入图片描述
2、配置页面
在这里插入图片描述

"app-plus": {
	"titleNView": {
		"buttons": [
			{
				"color": "#5F3DB8",
				"fontSize": "50rpx",
				"text": "\ue6a4",
				"fontSrc": "static/fonts/uniicons.ttf"
			}
		]
	}
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

fontSrc 填写static下的uniicons.ttf地址,注意写准确。

text 填写图标的名字。可以到此地址查询需要的图片:https://uniapp.dcloud.net.cn/component/uniui/uni-icons.html
在这里插入图片描述

复制需要的图片名称到uniicons_file.ts中搜索,我这里添加的是gift,就把 unicode 的值 \ue6a4 填写到text

在这里插入图片描述
4、绑定点击事件

onNavigationBarButtonTap(e) {
	console.log('自定义按钮被点击')
}
  • 1
  • 2
  • 3

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Li_阴宅/article/detail/802516
推荐阅读
相关标签
  

闽ICP备14008679号