1.wepy组件只有onLoad生命周期
2.wepy组件url路径只能导入网络路径,本地路径无效
<style scoped lang="scss">
.empty-placeholder {
padding-top: 290rpx;
width: 100%;
text-align: center;
.emptyImg{
width: 203rpx;
display: block;
margin: 0 auto;
}
.txt {
font-size: 26rpx;
color: #848484;
margin-top: 26rpx;
}
}
</style>
<template>
<view class="empty-placeholder" wx:if="{{show}}">
<image class="emptyImg" wx:if="{{emptyInfo[type].icon}}" src="{{emptyInfo[type].icon}}" bindload="getImgSize" binderror="getError" style="height: {{height}}rpx" />
<view class="txt">{{emptyInfo[type].text}}</view>
</view>
</template>
<script>
import wepy from "wepy";
export default class Placeholder extends wepy.component {
props = {
show: {
type: Boolean,
default: false
},
type: String,
};
data = {
height:0,
emptyInfo:{
qd:{
// icon:"../images/img/c1@2x.png",无效,请使用网络路径
icon:wepy.$instance.globalData.cloudPath + "/myCase/noCase.png",
text:"暂无清单信息",
}
},
}
methods = {
getImgSize(e){
console.log(e,"e")
let {width,height} = e.detail;
let scale;
if(width > height){
scale = width/height;
}else {
scale = height/width;
}
this.height = 203/scale;
},
getError(e){
console.log("图片载入失败触发",e)
/*this.emptyInfo[this.type].icon = this.emptyInfo[this.type].icon + " "
this.$apply();
console.log(this.emptyInfo[this.type].icon,"啦啦啦啦")*/
}
}
}
</script>
3.报错:
element parse error: Error invalid tagName: @#[line:1,col:3]
组件中用了某个属性,但是父组件传过来的数据里面没有改字段