javascript中应用的类似物是什么?创建了一个对象:
const button = {
title: "",
setTitle(text){
this.title = text
},
render() {
return `<a href="#" class="button">
${this.title}
</a>`
},
apply(func){
return func()
}
};
我打电话:
button.apply(function() {
this.title = 's';
this.render();
})
但他写道,渲染不是一个函数。怎么了?如何实现这样的事情?
有点不清楚你想要什么。也许你需要它?