我在退出应用时尝试进行验证,但在使用AlertController离子2时遇到错误:我按照https://ionicframework.com/docs/api/components/alert/AlertController/
上的说明操作对不起,我不擅长英语
我的错误:
Uncaught TypeError: Cannot read property 'create' of undefined
at Object.MyApp.exit [as fn] (main.js:143575)
at Platform.runBackButtonAction (main.js:2347)
at main.js:2022
at SafeSubscriber.schedulerFn [as _next] (main.js:54953)
at SafeSubscriber.__tryOrUnsub (main.js:1388)
at SafeSubscriber.next (main.js:1337)
at Subscriber._next (main.js:1290)
at Subscriber.next (main.js:1254)
at EventEmitter.Subject.next (main.js:7763)
at EventEmitter.emit (main.js:54927)
at main.js:104021
at t.invoke (polyfills.js:3)
at Object.onInvoke (main.js:38895)
at t.invoke (polyfills.js:3)
at e.run (polyfills.js:3)
我的代码app.component.ts:
答案 0 :(得分:0)
尝试此代码
exit(){
this.alertCtrl.create({
title :'' ,
subTitle:'',
buttons:['']
}).then(alertEt =>{
alertEt.present();
})
}