onBackPressed
FxUI.fs.onBackPressed(Object object)
# 功能描述
该方法允许您拦截设备的物理返回按钮
# 参数
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
fn | 拦截的钩子回调 | Function | — | — |
pageid | 页面id | number | — | — |
# 代码示例
该方法通过fn接收回调,示例如下:
import FxUI from 'fxui-mobile';
Component({
methods: {
onBackPressed() {
//拦截物理返回键返回,通知上层页面关闭
//true 拦截
//false 不拦截
return true or false
}
},
lifetimes:{
attached() {
FxUI.fs.onBackPressed({
fn: this.onBackPressed.bind(this),
pageid: this.getPageId && this.getPageId()
});
}
}
)}