日期:2020-01-28 阅读:686
dmandwp系统 - wordpress系统和DM系统区块建站>>
小程序组件:https://developers.weixin.qq.com/miniprogram/dev/component/
https://developers.weixin.qq.com/miniprogram/dev/component/navigator.html
-------
<view class="btn-area">
<navigator url="/page/navigate/navigate?title=navigate" hover-class="navigator-hover">跳转到新页面</navigator>
<navigator url="../../redirect/redirect/redirect?title=redirect" open-type="redirect" hover-class="other-navigator-hover">在当前页打开</navigator>
<navigator url="/page/index/index" open-type="switchTab" hover-class="other-navigator-hover">切换 Tab</navigator>
<navigator target="miniProgram" open-type="navigate" app-id="" path="" extra-data="" version="release">打开绑定的小程序</navigator>
</view>
==============
微信小程序笔记——处理小程序页面栈限制(小程序wx.navigateTo封装)
小程序中页面栈最多十层,随着页面增加路由跳转很容易在不知道的情况下就会堆栈到十层,再用navigateTo去跳转就跳不动了。
这时候就需要删除当前页面栈(redirectTo)或删除所有页面栈(reLaunch)来跳转了。页面栈可以通过getCurrentPages方法获取。
https://blog.csdn.net/zuorishu/article/details/93618624
https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.reLaunch.html
wx.reLaunch({
url: 'test?id=1'
})
// test
Page({
onLoad (option) {
console.log(option.query)
}
})
navigateRoute.js:
function navigateTo(url) {
if (getCurrentPages().length >= 10) {
wx.redirectTo({
url: url,
success: function (res) { },
fail: function (res) { },
complete: function (res) { },
})
} else {
wx.navigateTo({
url: url,
})
}
}
module.exports = navigateTo
---------------
js引用:
import navigateTo from "../../utils/navigateRoute.js"
navigateTo('/pages/public/postDetail/postDetail?id=' + e.currentTarget.dataset.id)