小程序
小游戏
企业微信
微信支付
扫描小程序码分享
5 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
马上都2022年了,我还是没有能解决自定义tabbar的这个问题
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
这个要怎么解决,同问
解决了吗?
https://developers.weixin.qq.com/community/develop/doc/0006045c4400b898e588b24035b014?_at=1567045628714
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
组件wxml
<
view
class
=
"tabbar_box {{isIphoneX?'iphoneX-height':''}}"
style
"background-color:{{tabbar.backgroundColor}}"
>
block
wx:for
"{{tabbar.list}}"
wx:key
"{{item.pagePath}}"
navigator
"tabbar_nav"
hover-stop-propagation
hover-class
"none"
url
"color:{{item.selected ? tabbar.selectedColor : tabbar.color}}"
open-type
"switchTab"
image
"tabbar_icon"
src
"{{item.selected ? item.selectedIconPath : item.iconPath}}"
></
text
>{{item.text}}</
</
const app = getApp();
Component({
properties: {
tabbar: {
type: Object,
value: {
"backgroundColor"
:
"#ffffff"
,
"color"
"#979795"
"selectedColor"
"#1c1c1b"
"list"
: [{
"pagePath"
"pages/bussiness/home/home"
"text"
"tabbar一"
"iconPath"
"images/tabbar/bussiness.png"
"selectedIconPath"
"images/tabbar/bussiness_select.png"
},
{
"/pages/message/message/message"
"/images/banner.png"
"isSpecial"
true
"tabbar三"
"pages/card/card/card"
"tabbar四"
"images/tabbar/find.png"
"images/tabbar/find_select.png"
]
}
})
app onlaunch
onLaunch:
function
(options) {
//隐藏系统tabbar
wx.hideTabBar();
//获取设备信息
this
.getSystemInfo();
app.js
getSystemInfo:
() {
let t =
;
wx.getSystemInfo({
success:
(res) {
t.globalData.systemInfo = res;
});
editTabbar:
let tabbar =
.globalData.tabBar;
let currentPages = getCurrentPages();
let _this = currentPages[currentPages.length - 1];
let pagePath = _this.route;
(pagePath.indexOf(
'/'
) != 0) && (pagePath =
+ pagePath);
for
(let i
in
tabbar.list) {
tabbar.list[i].selected =
false
(tabbar.list[i].pagePath == pagePath) && (tabbar.list[i].selected =
);
_this.setData({
tabbar: tabbar
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
马上都2022年了,我还是没有能解决自定义tabbar的这个问题
这个要怎么解决,同问
解决了吗?
https://developers.weixin.qq.com/community/develop/doc/0006045c4400b898e588b24035b014?_at=1567045628714
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
组件wxml
<
view
class
=
"tabbar_box {{isIphoneX?'iphoneX-height':''}}"
style
=
"background-color:{{tabbar.backgroundColor}}"
>
<
block
wx:for
=
"{{tabbar.list}}"
wx:key
=
"{{item.pagePath}}"
>
<
navigator
class
=
"tabbar_nav"
hover-stop-propagation
hover-class
=
"none"
url
=
"{{item.pagePath}}"
style
=
"color:{{item.selected ? tabbar.selectedColor : tabbar.color}}"
open-type
=
"switchTab"
>
<
image
class
=
"tabbar_icon"
src
=
"{{item.selected ? item.selectedIconPath : item.iconPath}}"
></
image
>
<
text
>{{item.text}}</
text
>
</
navigator
>
</
block
>
</
view
>
组件jsconst app = getApp();
Component({
properties: {
tabbar: {
type: Object,
value: {
"backgroundColor"
:
"#ffffff"
,
"color"
:
"#979795"
,
"selectedColor"
:
"#1c1c1b"
,
"list"
: [{
"pagePath"
:
"pages/bussiness/home/home"
,
"text"
:
"tabbar一"
,
"iconPath"
:
"images/tabbar/bussiness.png"
,
"selectedIconPath"
:
"images/tabbar/bussiness_select.png"
},
{
"pagePath"
:
"/pages/message/message/message"
,
"iconPath"
:
"/images/banner.png"
,
"isSpecial"
:
true
,
"text"
:
"tabbar三"
},
{
"pagePath"
:
"pages/card/card/card"
,
"text"
:
"tabbar四"
,
"iconPath"
:
"images/tabbar/find.png"
,
"selectedIconPath"
:
"images/tabbar/find_select.png"
},
]
}
}
},
})
app onlaunch
onLaunch:
function
(options) {
//隐藏系统tabbar
wx.hideTabBar();
//获取设备信息
this
.getSystemInfo();
},
app.js
getSystemInfo:
function
() {
let t =
this
;
wx.getSystemInfo({
success:
function
(res) {
t.globalData.systemInfo = res;
}
});
},
editTabbar:
function
() {
let tabbar =
this
.globalData.tabBar;
let currentPages = getCurrentPages();
let _this = currentPages[currentPages.length - 1];
let pagePath = _this.route;
(pagePath.indexOf(
'/'
) != 0) && (pagePath =
'/'
+ pagePath);
for
(let i
in
tabbar.list) {
tabbar.list[i].selected =
false
;
(tabbar.list[i].pagePath == pagePath) && (tabbar.list[i].selected =
true
);
}
_this.setData({
tabbar: tabbar
});
},