![](/img/trans.png)
[英]cannot read property addOption on undefine in javascript selectize
[英]Cannot read property … of undefine , at Object.callbackFromNative In angular 2
我有一個流代碼
declare var Speech: any;
export class Lesson implements OnInit {
text = '';
constructor()
{
this.text = 'hh';
}
ToSpeech(){
Speech.listen(this.listenSucess);
}
listenSucess(result){
this.text = reuslt;
}
文件Speech.js
var Speech= (function () {
return {
listen:funtion(sucess){
window.plugins.speechRecognition.startListening(function (result) {
success(result);
}
}
}
我有一個錯誤,如:
Cannot read property 'this.text' of undefined
at Object.callbackFromNative
我將回調用於此功能,謝謝。
您是否嘗試過胖箭頭=>
而不是function
? 因為this
在function
內部無法訪問
var Speech = (() => {
return {
listen = (success) => {
window.plugins.speechRecognition.startListening((result) => {
success(result);
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.