大家好,
請問一下如果要assign 一個static variable 給另外一個static variable 要怎麼辦
class chartAction {
static def_station =
[
'[30 HK Grids] ',
'[WGL] ',
'[WGL] ',
'[SE] ',
'[SE] ',
'[SE] ',
'[SE] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[Sum of 30 HK Grids] ',
'[30 HK Grids] ',
'',
''
];
static station = def_station; <= !!!!!!! 就是這裡
static abc;
constructor() {
this.abc = this.station <= !!!!!!! 怎樣ASSIGN STATION
}
}
前面加 this.
即可
class ChartAction {
static def_station = [
'[30 HK Grids] ',
'[WGL] ',
'[WGL] ',
'[SE] ',
'[SE] ',
'[SE] ',
'[SE] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[Sum of 30 HK Grids] ',
'[30 HK Grids] ',
'',
''
];
static station = this.def_station;
}
class chartAction {
static def_station =
[
'[30 HK Grids] ',
'[WGL] ',
'[WGL] ',
'[SE] ',
'[SE] ',
'[SE] ',
'[SE] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[30 HK Grids] ',
'[Sum of 30 HK Grids] ',
'[30 HK Grids] ',
'',
''
];
static station = this.def_station;
static abc;
constructor() {
chartAction.abc = chartAction.station;
}
}
console.log(chartAction.abc);//undefined
let a = new chartAction();
console.log(chartAction.abc);