[英]Emitting Event from node_modules to vue
如何接收 node_module 發出的事件? 想要在 vue 文件中接收它。
這是來自js node_module:
const EventEmitter = require('events')
class Find extends EventEmitter {
// some codes here
}
class FindInPage extends Find {
constructor (webContents, options = {}) {
super(webContents)
}
initialize () {
this.on('onValueInput', (value) => {
console.log('onValueInput received, value = ' + value)
})
}
// emit event triggered somewhere after
this.emit('onValueInput', this[findInput].value)
}
在我的 vue 文件中,我正在從 js node_module 實例化 class 並且我想接收事件:
this.findInPage = new FindInPage(this.$q.electron.remote.getCurrentWebContents(), configToApply)
this.findInPage.on('onValueInput', (value) => {
console.log('onValueInput received from module, value = ' + value)
})
但我沒有收到onValueInput
事件。 它在 js 模塊中運行良好。 請幫忙!
這現在有效。 顯然,這只是一個打錯電話的案例。 多謝你們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.