美文网首页
vue动态设置图片src属性

vue动态设置图片src属性

作者: 不期而遇_3491 | 来源:发表于2019-04-17 16:06 被阅读0次

<template>

    <div @click="home">

      <img :src="home_url" alt="..." style="height: 10vw">

    </div>

</template>

<script>

  // 下面是导入两张图片的相对地址

  import home_no from '../static/icon/home_no.png'

  import home from '../static/icon/home.png'

  export default {

    name: "newbase",

    data () {

      return {

        home_url: home

      }

    },

    methods: {

      home() {

        this.home_url = home

      }

    }

  }

</script>

---------------------

作者:haeasringnar

来源:CSDN

原文:https://blog.csdn.net/haeasringnar/article/details/81293020

版权声明:本文为博主原创文章,转载请附上博文链接!

也可以使用imgSrc:require("../../../assets/p3.jpg"),这种方式

相关文章

网友评论

      本文标题:vue动态设置图片src属性

      本文链接:https://www.haomeiwen.com/subject/nkpnwqtx.html