Javascript 将其嵌套在Stencil.js组件中
我想知道在Stencil.js组件中使用嵌套的“this”是否有更简单的方法 目前我正在这样做:Javascript 将其嵌套在Stencil.js组件中,javascript,typescript,jsx,stenciljs,tsx,Javascript,Typescript,Jsx,Stenciljs,Tsx,我想知道在Stencil.js组件中使用嵌套的“this”是否有更简单的方法 目前我正在这样做: render() { let thisNested = this; return <Host> {this.images ? this.imagesArray.map(function (el) { return <img // @ts-ignore
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>;
}
render(){
让thisNested=this;
返回
{这是你的照片吗?
this.imagesArray.map(函数(el){
返回
}) : }
;
}
但我总是重复自己写一个嵌套的变量,如上图所示
有没有更优雅的方式来满足我的需求?使用箭头功能:
render(){
返回
{这是你的照片吗?
this.imagesArray.map((el)=>(
)) : }
;
}