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>

 

posted @ 2019-07-29 17:52  sx00xs  阅读(428)  评论(0编辑  收藏  举报