switchTap跳转失败
发布于 5 年前 作者 gang44 10116 次浏览 来自 问答

点击跳转没反应,为什么呢?

新建一个小程序把代码和相关文件复制进去却可以跳转。

app.json:

{

“pages”: [

“pages/welcome/welcome”,

“pages/post/post”,

“pages/movie/movie”,

“pages/post/post-comment/post-comment”,

“pages/post/post-detail/post-detail”

],

“window”: {

“navigationBarBackgroundColor”: “#4A6141”

},

“tarBar”:{

“borderStyle”:“white”,

“selectedColor”:"#4A6141",

“color”:"#333",

“backgroundColor”:"#fff",

“position”:“bottom”,

“list”:[

{

“pagePath”:“pages/post/post”,

“text”:“文字”,

“iconPath”:“images/icon/wx_app_news.png”,

“selectedIconPath”:“images/icon/[email protected]

},

{

“pagePath”:“pages/movie/movie”,

“text”:“光影”,

“iconPath”:“images/icon/wx_app_movie.png”,

“selectedIconPath”:“images/icon/[email protected]

}

]

}

}

pages/welcome/welcome.js:

onTapJump: function (event) {

wx.switchTab({

url: ‘…/post/post’

})

},

<!–pages/welcome/welcome.wxml–>

<view class=“container”>

<image class=“avatar” src="…/…/images/avatar/avatar1.jpg"> </image>

<text class=“motto”>Hello</text>

<view catchtap=‘onTapJump’ class=“journey-container”>

<text class=“journey”>开启小程序之旅</text>

</view>

</view>

2 回复

你好,经测试,在switchTab的URL的路径研跟json的配置路径一致即可

原来是“tarBar"错了,应该改为”tabBar"。[苦笑]

回到顶部