亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue的v-for之后的click事件

vue的v-for之后的click事件

當年話下 2019-03-22 23:15:00
問題描述用vue的for循環,寫了一些div,但是我需要在綁定的div的子/孫節點上面添加click事件,我怎么取得當前的這個對象,或則怎么實現點擊哪個 哪個變色的效果,而不是全部?。?! 我已經寫了一個簡單的頁面,請幫忙調試!<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>Document</title>    <script src="https://cdn.bootcss.com/vue/2.6.9/vue.min.js"></script>    <style>        * {            padding: 0;            margin: 0;        }        .boxlist {            width: 100%;            height: auto;            border: 1px solid grey;            padding: 20px;        }        .box {            height: 100px;            width: 100%;            border: 1px solid green;        }        .showbox {            width: 100%;            height: 50px;            background-color: bisque;        }        .editbox {            width: 100%;            height: 50px;            background-color: chartreuse;        }    </style></head><body>    <div class="boxlist">        <div class="box" v-for="item in list">            <div class="showbox" v-if="showbox">                <div class="title"></div>                <div class="header">header</div>                <input type="button" value="編輯" @click="showval" />            </div>            <div class="editbox" v-else>                <div class="title">111</div>                <input type="button" value="保存" @click="hideval" />            </div>        </div>    </div>    <script>        new Vue({            el: ".boxlist",            data: {                list: [1, 2, 3, 4, 5],                showbox: true            },            methods: {                showval: function () {                    this.showbox = false                },                hideval: function () {                    this.showbox = true                }            }        })    </script></body></html>
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1712 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號