el-tree的图标绑定事件
时间: 2023-10-10 07:09:46 浏览: 110
在el-tree标签中,图标可以通过给slot-scope中的data属性添加icon属性来进行绑定。具体的代码如下所示:
```html
<span slot-scope="{ node, data }">
<i :class="data.icon" style="font-size:0.3rem" @click="handleIconClick(data)" />
<span style="padding-left:4px;font-size:0.3rem">{{ data.name }}</span>
</span>
```
在上述代码中,通过给<i>标签添加@click事件来绑定图标的点击事件,同时传递data对象作为参数。你可以在handleIconClick方法中处理图标的点击事件。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [给el-tree添加自定义图标](https://blog.csdn.net/weixin_43258184/article/details/124813423)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文