You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/05/08 08:59:42 UTC
[GitHub] [incubator-weex] ZhiPengTu edited a comment on issue #2405: [weex playground][iOS][Dev-tool] 刷新页面 导致 调试工具闪退
ZhiPengTu edited a comment on issue #2405: [weex playground][iOS][Dev-tool] 刷新页面 导致 调试工具闪退
URL: https://github.com/apache/incubator-weex/issues/2405#issuecomment-490406451
### 这个是暂时前端的解决方案, 在onImageLoad() 时,获取image的宽高,在@appear的时候,使用 animate 动态改变 宽高,刷新闪退的原因是在加载的时候,突然开启多个 animate 动画效果,可能导致内存溢出 ,直接闪退(猜测),所以才去异步改变的方式 来解决,解决闪退的问题
``` javascript
<image v-for="(item,index) in detailImageList" @appear="ImageAppear(index)" class="xxxxtest" ref="img" @load="onImageLoad(index,$event)" :src="item.url" ></image>
```
``` javascript
ImageAppear(index){
var _that=this;
const view = this.$refs['img'];
console.log(index)
if (Utils.env.isWeb()){
view[index].style.width= '10rem';
view[index].style.height= _that.detailImageList[index].height;
}else{
animation.transition(view[index],{
styles:{
width: '750px',
height: _that.detailImageList[index].height
},
duration: 0,//需要设置为0,否则无效
timingFunction:'ease',
delay: 0,
needLayout:true,//变化后刷新界面
}, function(){
console.log(1)
})
};
// }
},
//获取 image 实际宽高
onImageLoad (index,event) {
var that=this;
if (event.success) {
const view = that.$refs['img'];
if (event.success){
if (Utils.env.isWeb()){
that.detailImageList[index].width='10rem';
that.detailImageList[index].height= `${10*event.size.naturalHeight/event.size.naturalWidth}rem`;
}else{
that.detailImageList[index].width='750px';
that.detailImageList[index].height= `${750*event.size.naturalHeight/event.size.naturalWidth}px`;
}
}
}
},
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services