problem:
ColorUI-UniApp navigation bar to return only to go back, how to set a custom page?
Resolution:
1. Locate the navigation component cu-custom.vue under colorUi
2. Define a custom navigation attributes url
props: {
// 定义一个导航url属性,如果有这个属性就使用这个跳转url
url: {
type: String,
default: ''
}
},
3. Modify the jump method
BackPage() {
if (this.url) {
uni.redirectTo({url: this.url})
} else {
if (getCurrentPages().length < 2 && 'undefined' !== typeof __wxConfig) {
let url = '/' + __wxConfig.pages[0]
return uni.redirectTo({
url
})
}
uni.navigateBack({
delta: 1
});
}
}
4. How to pass url value it?
Such a jump from page to page b, c and then jump back to a page from b, b to c jump from the last page. If you do not set a custom url attribute, click c page return jump directly to a page, in order to solve this problem in the jump from b to c page when the page is passed to a relative path b c c page as the page jump back b to url to the page.
<navigator class="cu-item" navigateTo v-for="(user, index) in userData" :key="index" hover-class="none"
:url="jump(user)" open-type="redirect"></navigator >
// 跳转页面
jump: function(loan) {
let data = {
title: '用户详情',
url: '../user/user-query' // 注意这个地址是a页面跳转到b(当前页)的相对地址
}
return this.contract(this.sonUrl, data)
}