【发布时间】:2020-08-09 06:49:15
【问题描述】:
我想知道是否有更简单的方法可以在 Stencil.js 组件中使用嵌套的“this”。
目前我正在这样做:
render() {
let thisNested = this;
return <Host>
{this.images ?
this.imagesArray.map(function (el) {
return <img
// @ts-ignore
src={thisNested.imageSize ? thisNested.imageSize : el.url}/>
}) : <slot/>}
</div>
</Host>;
}
但我总是重复自己写一个嵌套的这个变量,如上所示。
有没有更优雅的方式来做我需要的事情?
【问题讨论】:
标签: javascript typescript jsx stenciljs tsx