标签:function selected eth new pkg vue text otto containe
<script src="https://unpkg.com/vue/dist/vue.js"></script> <style type="text/css"> .blue{ background-color: blue; } .green{ background-color: green; } div{ width: 400px; height: 200px; border-bottom-width: 2px; } </style> <div id="container"> <div v-for="item in someData" class="blue" v-bind:class="{‘green‘: item.selected }" @click="green(item)"> 点我 </div> </div> <script> var vm = new Vue({ el: ‘#container‘, data: { someData: [{"id":1,selected:true},{"id":2,selected:false},{"id":3,selected:true}] }, methods:{ green:function(item){ item.selected=!item.selected; } } }) </script>
标签:function selected eth new pkg vue text otto containe
原文地址:http://www.cnblogs.com/longling2344/p/6890991.html