未定義的變量我有兩個關於離子3.離子3 - 在Ionic3
在我ionic3頁的問題,我宣佈一個名爲「測試」 whict不能在actionOnClick函數訪問變量。有人知道嗎?我應該怎麼做才能在FUNCTION_TEST函數中'可測試'任何可訪問的東西?
有沒有辦法使HomePage和FUNCTION_TEST之間的變量交換成爲可能?
波紋管是我的ionic3代碼。
import { Component,ViewChild } from '@angular/core';
import { NavController } from 'ionic-angular';
import {Content} from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild(Content) content:Content;
test:string="text 1";
constructor(public navCtrl: NavController) {
}
ionViewDidEnter(){
this.FUNCTION_TEST();
}
FUNCTION_TEST(){
var x=1;
function actionOnClick(){
alert("text="+this.test);
}
}
}
是否有可能我的問題與JavaScript而不是與離子?
非常感謝您的幫助!
可能重複https://stackoverflow.com/questions/22939130/when-should-i-use-arrow-functions-in-ecmascript-6 –