Today, in the process of writing a WeChat applet, I found that navigateTo was invalid. After repeated inspections, I found that the code was not wrong. After checking the Internet, I found the problem.
Added the navigation bar to app.json as follows:
"tabBar"
: {
"color"
:
"red"
,
"size"
:
"50px"
,
"list"
: [{
"pagePath"
:
"pages/index/index"
,
"text"
:
"首页"
},{
"pagePath"
:
"pages/test/test"
,
"text"
:
"Test Page"
}]
}
Setting the bintap event in the test page also jumps to the index page as follows:
in test.wxml is
<
button
bindtap
=
"toIndex"
size
=
"mini">
首页
</
button
>
in test.js is
toIndex:
function
() {
//console.log(111)
wx.navigateTo({
url:
'../index/index'
})
},
As a result, the click event in test.js does not respond. Looking for a solution, it is found that when the navigation bar and navigateTo point to the same url, navigateTo fails. Therefore, choose one of the two to achieve it.