class Parent{
method(){
console.log("Parent");
}
}
class Child extends Parent{
method(){
console.log("Parent");
}
}
var child = new Child();
console.log(child.method);
Run Code Online (Sandbox Code Playgroud)
子类中的控制台返回方法是预期的行为。
class Parent{
method = "sss"
}
class Child extends Parent{
method(){
console.log("Child")
}
}
var child = new Child();
console.log(child.method)
Run Code Online (Sandbox Code Playgroud)
为什么控制台在父类中返回方法变量 - “sss”?