uni 加入图标_uniapp如何更改图标

Uniapp更改图标的方法:首先,将图标文件中的“iconfont.ttf”放入静态文件夹;然后打开“iconfont.css”,查看unicode编码;最后,在配置项“page.json”中填写对应图标的代码。

本教程操作环境:Windows7系统,uni-app版本2.5.1,此方法适用于所有品牌的电脑。

推荐(免费):统一应用开发教程

统一应用添加顶部导航栏并更改图标

Uni-app是一个使用Vue.js开发跨平台应用的前端框架

开发者通过编写Vue.js代码,将其编译到iOS、Android、微信小程序等平台,保证其正确运行,体验极佳。

记录更换顶部导航栏的过程

最终效果图

page.json中的配置项

{ & quot路径& quot:& quot页面/我的/索引& quot,& quot样式& quot:{ & quotapp-plus & quot;:{ & quot标题视图& quot:{ & quot按钮& quot:

收藏夹图标

2.下载右上角收集的所有图标

下载

3.在编辑器中打开下载的文件,将文件中的iconfont.ttf扔到静态文件夹中,然后打开iconfont.css查看unicode编码

Unicode编码

4.最后,在page.json的配置项中填写对应图标的代码,需要写成“\ u * * * & quot,然后重新启动它

5.最后填写相应的页面生命周期方法,通过e.index配置不同的方法

onnavigationbuttontap:function(e){ console . log(JSON . stringify(e))},以上是uniapp如何更改图标的细节,还有更多。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我了解了您的问题。首先,要实现底部导航栏中间凸起的效果,可以使用uni-ui组件库中的tabBar组件。在tabBar组件中,可以设置中间按钮为凸起样式,并使用自定义图标和文本。 接下来,我将为您介绍如何使用uni-ui中的tabBar组件,并实现中间凸起的效果。 1. 安装uni-ui组件库 在HBuilderX中,打开您的uni-app项目,选择菜单栏的“工具”-“插件市场”,搜索并安装“uni-ui”组件库。 2. 引入tabBar组件 在需要使用tabBar组件的页面中,引入tabBar组件: ```html <template> <view> <tab-bar :tabList="tabList" :current="current" @change="changeTab"></tab-bar> </view> </template> <script> import tabBar from '@/uni-ui/tabBar/tabBar.vue' export default { components: { tabBar }, data() { return { tabList: [ { pagePath: '/pages/home/home', text: '首页', iconPath: '/static/tabbar/home.png', selectedIconPath: '/static/tabbar/home-active.png' }, { pagePath: '/pages/video/video', text: '视频', iconPath: '/static/tabbar/video.png', selectedIconPath: '/static/tabbar/video-active.png' }, { pagePath: '/pages/mine/mine', text: '我的', iconPath: '/static/tabbar/mine.png', selectedIconPath: '/static/tabbar/mine-active.png' } ], current: 0 } }, methods: { changeTab(e) { this.current = e.index uni.switchTab({ url: this.tabList[e.index].pagePath }) } } } </script> ``` 在上述代码中,tabList数组中定义了三个tab,分别对应三个页面。通过设置iconPath和selectedIconPath属性,可以设置未选中和选中状态下的图标。在changeTab方法中,通过uni.switchTab方法实现tab之间的切换。 3. 实现中间凸起的效果 要实现中间凸起的效果,可以在tabBar组件中添加一个自定义的tab,设置其样式为凸起,并与其他tab一起渲染。在changeTab方法中,可以通过判断当前点击的tab是否为自定义tab,来实现特殊处理。 ```html <template> <view class="tab-bar"> <view class="tab" v-for="(item, index) in tabList" :key="index" @click="changeTab({index})"> <view :class="['icon', current === index ? 'active' : '']"> <image :src="current === index ? item.selectedIconPath : item.iconPath"></image> <text>{{item.text}}</text> </view> <view class="custom-tab" v-if="index === 1" @click.stop="changeTab({index: -1})"> <image src="/static/tabbar/plus.png"></image> </view> </view> </view> </template> <script> export default { props: { tabList: { type: Array, default: [] }, current: { type: Number, default: 0 } }, methods: { changeTab(e) { if (e.index === -1) { // 点击自定义tab的处理逻辑 // ... } else { this.$emit('change', e) } } } } </script> <style scoped> .tab-bar { display: flex; justify-content: space-between; align-items: center; height: 100rpx; background-color: #fff; } .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; } .icon { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 24rpx; color: #666; } .active .icon { color: #f00; } .custom-tab { position: absolute; left: 50%; transform: translateX(-50%); bottom: 10rpx; width: 80rpx; height: 80rpx; border-radius: 50%; background-color: #f00; display: flex; align-items: center; justify-content: center; } .custom-tab image { width: 50rpx; height: 50rpx; } </style> ``` 在上述代码中,通过v-if指令判断当前渲染的tab是否为自定义tab(即第二个tab),如果是则渲染一个自定义tab,并设置其样式为凸起。在changeTab方法中,通过判断点击的tab的index是否为-1,来判断是否点击了自定义tab。 至此,您已经了解了如何使用uni-ui中的tabBar组件,并实现底部导航栏中间凸起的效果。接下来,您可以继续开发您的小视频应用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值