-
vue项目中使用默认图片代替异常图片
- 第一种方法
<img onerror="javascript:this.src='../../static/custom.png';" class="customerHead" :src="param.customerHead" alt="">
图片不存在时,触发 onerror,显示custom.png
- 第二种方法
<img :onerror="errpic" class="customerHead" :src="param.customerHead" alt="">
data() { return { errpic:'this.src="' + require('../../assets/img/errpic.png') + '"', } }
vue 替换图片
<img :src="calcuImgUrl" alt="">
data() { return { calcuImgUrl:require('../../assets/img/calcu0.png') } }
mounted(){if(G.calculateState=="2"){ this.calcuImgUrl = require('../../assets/img/calcu2.png'); } },
vue watch 监听
watch:{ param:{ handler(val,oldval){ var ct=this.param.certificate; var cf=this.param.certificateNum; if((ct==""||ct==null)&&(cf==""||cf==null)){ this.disabled_startname=true; this.disabledInput=true; this.disabledVild=true; } }, deep:true //深度监听 } },
vue computed 计算属性
computed:{ complate_message(){ if(this.param.weight !== "" && this.param.height !==""){ let BMI =Math.round(this.param.weight/((this.param.height/100)*(this.param.height/100))*10)/10 return BMI }else{ return 0 } }, },
vue disabled属性更改
<div class="public_container">
<li class="style-li-css6">证件号码:</li>
<input type="text" ref="certificateNum"v-on:blur="changeAge(param.certificateNum)" v-model="param.certificateNum">
</li>
</div>
<div class="customer_sex" style="float:left;line-height:2;margin-left:35px;">
<el-checkbox :label="1" v-model="param.checked" @change="changeVid(param.checked)"
v-bind:disabled="disabledVild">长期有效</el-checkbox>
</div>
data(){ return { disabledVild:false } }
methods:{ onSelectedDrug(event,value) { if(value=="4"|value=="6"){
this.disabledVild=true; } }