Javascript 如何从文档对象继承到子对象
我试图从我的代码中的Javascript 如何从文档对象继承到子对象,javascript,Javascript,我试图从我的代码中的文档对象继承,但它不起作用,请说明如何实现这一点 这是我目前的代码: function Doc() { Document.call(this) } Doc.prototype = Object.create(Document.prototype); Doc.prototype.constructor = Doc; var userdoc = new Doc(); // it is not working when I try to do userdoc.que
文档
对象继承,但它不起作用,请说明如何实现这一点
这是我目前的代码:
function Doc() {
Document.call(this)
}
Doc.prototype = Object.create(Document.prototype);
Doc.prototype.constructor = Doc;
var userdoc = new Doc();
// it is not working when I try to do
userdoc.querySelectorAll('[abs-text]')
首先,你所说的“它不起作用”是什么意思?第二,为什么,为什么你一开始就需要/想要这样做?不太可能,不过如果你需要使用ES6
class
语法的话