<img :src="src" alt="" v-show="countRatio!=null">
在data里面分别定义,根据页面数据展示的条件赋值src,引入图片的时候,在data里定义
up: require('../../../assets/images/uppunish.png'),
在函数里赋值就可以了
if (res.countRatio!=null) {if (res.countRatio > 0) {this.src = this.up;this.countRatio = Math.round(res.countRatio * 100);} else if (res.countRatio < 0) {this.src = this.down;this.countRatio = Math.round(res.countRatio * 100).toString().replace('-', '');}} else {this.countRatio = null;}
data定义数据部分