【发布时间】:2018-10-13 05:36:09
【问题描述】:
我有桌子:
<table class="table table-condensed">
<thead>
<tr>
<th>id</th>
<th>task</th>
<th>date</th>
</tr>
</thead>
<tbody>
<tr v-for="row in tasks">
<td span @mouseover="showButtonFunction" @mouseleave="hideButtonFunction"> {{row.id}}</td>
<td span @mouseover="showButtonFunction" @mouseleave="hideButtonFunction"> {{row.text}}<button v-if="showBatton">Test</button></td>
<td span @mouseover="showButtonFunction" @mouseleave="hideButtonFunction"> {{row.date_current}}</td>
<td span @mouseover="showButtonFunction" @mouseleave="hideButtonFunction"><button v-if="showBatton">Test</button></td>
</tr>
</tbody>
</table>
按预期,按钮应该出现在鼠标悬停的行上。 但现在它出现在所有可见行上。
脚本:
data:{
showBatton:false,
},
showButtonFunction(){
// this.title="dsds2"
console.log("test")
this.showBatton=true;
},
hideButtonFunction(){
this.showBatton=false;
}
如何实现?
【问题讨论】:
标签: javascript vue.js html-table