![](/img/trans.png)
[英]How to access a component function from main.js in Vue 3 with Composition API
[英]how to access the function from console inside of build/main.js
我正在使用ionic / Angular,但似乎無法訪問webpack構建的js文件內部的功能。 當我打開chrome控制台並鍵入函數時,什么都沒有發生。.我在打字稿中嘗試了window.myfunction(),但它不喜歡該窗口。
我所做的模擬推送通知的方法是,在構造函數中,將App類導出到全局窗口
export class MyApp {
constructor(public platform: Platform) {
window["myapp"] = this; //<-- export the class into window
}
onNotification(data) {
//processNotification
}
}
然后,使用控制台,我可以模擬接收通知:
window.myapp.onNotification({additionalData:{type:“ test”,前景:true},消息:“這是消息”})
希望對您有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.