Vue练习四:01_04_点击将DIV变成红色

Demo 在线地址:
https://sx00xs.github.io/test/4/index.html
---------------------------------------------------------------
ide: vscode
文件格式:.vue
解析:(待补)

<template>
  <div id="app">
    <button @click="handleColor">点击将DIV变成红色</button>
    <div class="outer">
      <div v-for="n in 3" :key="n"
      :style="{background:activeColor}"
      ></div>
    </div>
  </div>
</template>
<script>
export default {
  data:function(){
    return{
      activeColor:'black'
    }
  },
  methods:{
    handleColor(){
      this.activeColor='red';
    }
  }
}
</script>
原文地址:https://www.cnblogs.com/sx00xs/p/11265463.html