const createText = (text) => {
const e = document.createElement('p')
e.innerHTML = text
return e
}
class CreateText {
...??
}
请问第一段创建元素的代码怎么用 ES6 的 Clsss 改写,使得下面的代码成立:
const foo = creatText('hello')
const bar = new CreateText('hello')
console.log(foo == bar) // print `true`
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
class一定要用new的
或许你可以这样写