<template>
<view>
123
<button type="default" @click="to()">返回</button>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
to () {
uni.showModal({
title:"测试",
content:'退出页面',
showCancel:true,
confirmText:'取消',
confirmText:'提交',
success: res=>{
if(res.confirm){
uni.navigateBack()
}
}
// success: function (res) {
// if(res.confirm){
// uni.navigateBack()
// }
// }
})
},
back () {
return new Promise((resolve,reject)=>{
})
}
},
onBackPress (event) {
console.log(123,event)
if(event.from === 'backbutton') {
uni.showModal({
title:"测试",
content:'退出页面',
showCancel:true,
confirmText:'取消',
confirmText:'提交',
success: res=>{
if(res.confirm){
uni.navigateBack()
}
}
// success: function (res) {
// if(res.confirm){
// uni.navigateBack()
// }
// }
})
return true
} else {
return false
}
}
}
</script>
<style>
</style>