vue里面动态更换图片

版权声明:未经本人同意不得转载 一切法律责任 后果自负 https://blog.csdn.net/xy19950125/article/details/83501360
<span @click="togle">
    <img :src=" this.i == 0 ? srcs : nosrc" alt="">
</span>

export default{
    data(){
        return{
            i:0,
            srcs:require('../images/[email protected]'),
            nosrc:require('../images/[email protected]')
        }
    },
    methods:{
        togle(){
            if(this.i==0){
               this.i=1;
            }else{
               this.i=0;
            }
        }
    }
}

猜你喜欢

转载自blog.csdn.net/xy19950125/article/details/83501360
今日推荐