The data is requested before entering the page. I have a requirement here, that is, if the backend code is not equal to 200, it will prompt the user with some error information and prevent the user from entering the next page. After looking at the official website, if you want to interrupt navigation, you can use next(false), but why does it not work if I return false here? Please help.
beforeRouteEnter (to, from, next) {
Vue.$uop.loading.show({
text: '加載中'
})
reqData.req({
apiName: 'getAddress'
}).then((res) => {
next((vm) => {
vm.$uop.loading.hide()
res = res.data
if (res && res.code !== 200) {
vm.$uop.toast.show({
type: 'text',
text: res.message
})
return false // 這里怎么寫才能不進(jìn)入下一個(gè)頁面
}
})
}).catch((error) => {
Vue.$uop.loading.hide()
Vue.$uop.toast.show({
type: 'text',
text: '請求地址數(shù)據(jù)異常'
})
})
認(rèn)證高級PHP講師
return false // How to write here so as not to enter the next page
next(false)
else
next()