vue按钮切换图片背景

非常好用,亲测可运行

<template>
  <v-app>
    <v-main>
      <v-btn
        class="error"
        @click="logoBtn">默认
      </v-btn>
      <v-btn
        class="primary"
        @click="taskBtn">课题
      </v-btn>
      <v-img
        max-height="150"
        max-width="250"
        :src="imagePath"
      ></v-img>
    </v-main>
  </v-app>
</template>

<script>
export default {
  data() {
    return {
      imagePath: null,
      status: true
    };
  },
  mounted() {
    this.imagePath = require("@/assets/task_left_bg.png");
  },
  methods: {
    logoBtn() {
      this.imagePath = require("@/assets/logo.png");
    },
    taskBtn() {
      this.imagePath = require("@/assets/task_left_bg.png");
    }
  }
};
</script>
<style
  scoped>
</style>

image.png