我有一个继承自ClassB
的类(对象)ClassAexport ClassA {
name: string;
phone: string;
}
export ClassC {
color: string;
}
export ClassB extends ClassA {
classC: ClassC;
list: string[];
}
在我的组件中我宣布
export class AppComponent {
classB: ClassB;
constructor() {
this.classB = new ClassB();
}
search() {
this.classB.classC.color = 'green';
}
}
当我调用搜索方法时,我在设置名称属性时出错
答案 0 :(得分:1)
仅定义了SELECT BOSS.*
FROM BOSS
INNER JOIN (
SELECT BOSS.ORI
, MIN(BOSS.cnt) cnt
FROM BOSS
WHERE BOSS.MANAGER IS NOT NULL
GROUP BY BOSS.ORI
) X
ON X.ORI = BOSS.ORI
AND X.cnt = BOSS.cnt
WHERE BOSS.ORI IN (3)
的类型。它必须初始化。你可以这样做。
classC
并且export ClassB extends ClassA{
constructor() {
super()
this.classC = new classC()
}
classC:ClassC;
list:string[];
}
,ClassA
和ClassB
必须作为类导出。
答案 1 :(得分:1)
在function foo() {
var searchTerm = "Something...";
var bnameonly = "Something else...";
function myCallback(data) {
if (typeof(data.parse) !== 'undefined') {
wikiHTML = data.parse.text["*"];
$wikiDOM = $("<table>"+wikiHTML+"</table>");
infobox = $wikiDOM.filter('.infobox.biota');
$("#wiki").contents().find('#myinfobox').html(infobox);
} else {
$("#wiki").contents().find('#myinfobox').html('');
}
}
var url="https://en.wikipedia.org/w/api.php?action=parse&format=json&page=" + searchTerm + "&redirects&prop=text&callback=?";
$.getJSON(url, {data}, myCallback);
if ($("#wiki").contents().find('#myinfobox').html() === '') {
var url="https://en.wikipedia.org/w/api.php?action=parse&format=json&page=" + bnameonly + "&redirects&prop=text&callback=?";
$.getJSON(url, {data}, myCallback);
}
}
课程中,您声明了一个名为ClassB
的成员classC
,但您从未对其进行初始化。试试这个:
ClassC