ES6 class之super

版权声明:任先阳 任 先 阳 任先 先阳,ifgm.cn、www.ifgm.cn、nvcc.cc、www.nvcc.cc、sbfox.com、www.sbfox.com https://blog.csdn.net/qq_39571197/article/details/86322614

super 不止那么简单,mdn-super 介绍也模模糊糊。

大致分为两种情况:静态方法中、构造器和原型方法中 

class Element{
		constructor() {
			this.setCreatedTime();
		}

		setCreatedTime() {
			super.timestamp = +new Date();
			console.log(super.timestamp); // undefined
			console.log(this.timestamp); // value
			console.log(super.setCreatedTime); // undefined
			console.log(this.setCreatedTime); // fn -> setCreatedTime
		}
	}

	const e = new Element();
	// console.log(e);

 研究不动,撤了,有时间我会再翻文档。。。。。

猜你喜欢

转载自blog.csdn.net/qq_39571197/article/details/86322614