我想让功能像这样执行:
输入:人们(' Z')waitFirst(5)
5秒后
输出://等待5秒
//我是Z~
function People(name) {
this.name = name;
setTimeout(console.log("I'm" +name+ "~"), 0);
return this;
}
People.prototype.waitFirst = function (time) {
new Promise((resolve, reject) => {
resolve();
}).then(() => {
setTimeout(console.log("waited" +time+ "s"), time * 1000);
});
}
但我收到错误未捕获TypeError:人(...)。waitFirst不是函数(...)
哪里出错了?