refactor: 移除 delta 属性并简化 goBack 方法逻辑
This commit is contained in:
@@ -40,11 +40,6 @@ Component({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
// 后退的层数
|
|
||||||
delta: {
|
|
||||||
type: Number,
|
|
||||||
value: 1,
|
|
||||||
},
|
|
||||||
// 标题最大长度,超出用 "…" 表示
|
// 标题最大长度,超出用 "…" 表示
|
||||||
titleMaxLength: {
|
titleMaxLength: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -118,25 +113,20 @@ Component({
|
|||||||
* 返回按钮点击事件
|
* 返回按钮点击事件
|
||||||
*/
|
*/
|
||||||
goBack() {
|
goBack() {
|
||||||
const pages = getCurrentPages()
|
wx.navigateBack({
|
||||||
const delta = this.properties.delta
|
success: (res) => {
|
||||||
if (pages.length > 1 && delta > 0) {
|
// 转发成功事件
|
||||||
wx.navigateBack({
|
this.triggerEvent('success', res)
|
||||||
delta,
|
// 转发完成事件
|
||||||
success: (res) => {
|
this.triggerEvent('complete', res)
|
||||||
// 转发成功事件
|
},
|
||||||
this.triggerEvent('success', res)
|
fail: (err) => {
|
||||||
// 转发完成事件
|
// 转发失败事件
|
||||||
this.triggerEvent('complete', res)
|
this.triggerEvent('fail', err)
|
||||||
},
|
// 转发完成事件
|
||||||
fail: (err) => {
|
this.triggerEvent('complete', err)
|
||||||
// 转发失败事件
|
},
|
||||||
this.triggerEvent('fail', err)
|
})
|
||||||
// 转发完成事件
|
|
||||||
this.triggerEvent('complete', err)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user