如何显示图标在表的特定行与onmouseover与Riot.js
How to show icon in specific row in table with onmouseover with Riot.js
我想在表主体的特定行中显示图标以删除该行。我寻找解决方案并尝试了,但效果不太好。
在所有行中显示图标很容易,但仅在特定行中显示图标却很困难。
下面的代码是我正在工作的简单版本。我希望有人知道解决办法。
<table>
<thead>
<tr>
<th>Title</th>
<th>Category</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr each={ article in articles } onmouseover={ onMouseOver }>
<td>{ article.title }<i class='fa fa-trash-o' aria-hidden='true' show={ parent.showTrash }></i></td>
<td>{ article.category }</td>
<td>{ article.date }</td>
</tr>
</tbody>
</table>
<script>
this.articles = [
{title: 'This is How Japanese Makeup' date: 'Oct 7 2016', category:'Makeup'},
{title: 'This is Japanese Fashion' date: 'Oct 8 2016', category:'Fashion'},
{title: 'This is Japanese Food' date: 'Oct 9 2016', category:'Food'}
]
onMouseOver(e) {
e.item.article.showTrash = true
}
</script>
您需要使用onmouseenter和onmouseleave来执行Delete的隐藏和显示。您不需要父show={ parent.showTrash }
,只需要文章,并且您在文章数组中遗漏了一个逗号。下面是代码
<table>
<thead>
<tr>
<th>Title</th>
<th>Category</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<tr each={ article in articles } onmouseleave={offTrash} onmouseenter={ onTrash }>
<td>{ article.title }<i class='fa fa-trash-o' aria-hidden='true' show={article.showTrash}> X </i></td>
<td>{ article.category }</td>
<td>{ article.date }</td>
</tr>
</tbody>
</table>
<script>
this.articles = [
{title: 'This is How Japanese Makeup', date: 'Oct 7 2016', category:'Makeup'},
{title: 'This is Japanese Fashion', date: 'Oct 8 2016', category:'Fashion'},
{title: 'This is Japanese Food', date: 'Oct 9 2016', category:'Food'}
]
onTrash(e) {
e.item.article.showTrash = true
}
offTrash(e) {
e.item.article.showTrash = false
}
</script>
在线版本:http://plnkr.co/edit/3lmsWA0RZ0zLERXQDdTr?p=preview
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 使用agility.js进行页面布局和合成
- 使用Clipboard.js复制span文本
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 强制模板刷新ember.js
- 如何编写HTML输入的JS内联
- Angular JS IE9 Hashbang url rewriting
- 使用JS将数组转换为json对象
- Node.js v6.2.0类扩展不是函数错误
- 当js函数's已执行
- 要求未定义JS回调参数
- 在自定义mean.io包中使用angular-chart.js作为依赖项
- 无法在数据endVal中设置值=“”;{{ucount}}”;使用Angular JS的CountUp
- 如何从Java/scala调用js美化程序
- 如何更改<svg>标记为<img>用js标记
- 如何使用 node.js 比较两个 json 数组
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- 节点Js:How to catch a“;没有这样的文件或目录“;读取线模块出错
- 如何显示图标在表的特定行与onmouseover与Riot.js
- 获取和设置字符串onmouseover js值