ColorUI | TabBar搬运
其实,它这个TabBar就是一个页面,页面里面分别添加其它组件构成分页。
理解了这些,就可以很容易搭建了
一、新建一个项目
二、拷贝到项目根目录
三、在app.wxss
中添加
@import "colorui/main.wxss";
@import "colorui/icon.wxss";
四、在app.js
里的 onLaunch: function() 里面添加
wx.getSystemInfo({
success: e => {
this.globalData.StatusBar = e.statusBarHeight;
let capsule = wx.getMenuButtonBoundingClientRect();
if (capsule) {
this.globalData.Custom = capsule;
this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
} else {
this.globalData.CustomBar = e.statusBarHeight + 50;
}
}
})
五、在将下面的内容替换掉app.json
的内容
{
"pages":[
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black",
"navigationStyle": "custom"
},
"usingComponents": {
"cu-custom": "/colorui/components/cu-custom"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
六、将...\ColorUI-master\demo\images\tabbar
里的\images\tabbar
按文件目录复制到项目根目录
七、将下面内容替换掉pages/index/index
对应内容
index.wxss
<view class="cu-bar tabbar bg-white shadow foot">
<view class="action" bindtap="NavChange" data-cur="basics">
<view class='cuIcon-cu-image'>
<image src="/images/tabbar/basics{{PageCur=='basics'?'_cur':''}}.png"></image>
</view>
<view class="{{PageCur=='basics'?'text-green':'text-gray'}}">元素</view>
</view>
<view class="action" bindtap="NavChange" data-cur="component">
<view class='cuIcon-cu-image'>
<image src="/images/tabbar/component{{PageCur=='component'?'_cur':''}}.png"></image>
</view>
<view class="{{PageCur=='component'?'text-green':'text-gray'}}">组件</view>
</view>
<view class="action" bindtap="NavChange" data-cur="plugin">
<view class='cuIcon-cu-image'>
<image src="/images/tabbar/plugin{{PageCur=='plugin'?'_cur':''}}.png"></image>
</view>
<view class="{{PageCur=='plugin'?'text-green':'text-gray'}}">扩展</view>
</view>
<view class="action" bindtap="NavChange" data-cur="about">
<view class='cuIcon-cu-image'>
<image src="/images/tabbar/about{{PageCur=='about'?'_cur':''}}.png"></image>
</view>
<view class="{{PageCur=='about'?'text-green':'text-gray'}}">关于</view>
</view>
</view>
index.js
Page({
data: {
PageCur: 'basics'
},
NavChange(e) {
this.setData({
PageCur: e.currentTarget.dataset.cur
})
},
})
八、结束
分类:
WeChat小程序学习
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!