文章来源:https://www.toymoban.com/news/detail-847644.html
<el-tree ref="sceneTreeRef" :filter-node-method="filterNode" class="scene-layer-tree" show-checkbox
node-key="nodeKey" :allow-drag="allowDragHandler" :allow-drop="allowDropHandler" @node-drop="handleDrop"
:data="TreeData.list" draggable default-expand-all @check="check">
<template #default="{ data }">
<span :title="data.title" class="tree-item-title">
<i class="fal fa-folder-open" style="color: #f2cc7b; margin: 5px" v-if="data.type == 'group'"></i>
<!-- 可以选择用一个< span >将整个< el-popover >包起来,给span加 一个 @click.stop,即可阻止冒泡 -->
<span @click.stop>
<el-popover placement="top" :width="200" trigger="click" class="propovers">
<template #reference>
<i class="fal fa-cog icon-setting"></i>
</template>
<template #default>
<div class="edit-item" v-if="data.type != 'root'" @click=editLayer(data)>
<i class="fal fa-edit"></i>
<span>{{ $t("x_edit") }}</span>
</div>
<div class="edit-item" v-if="data.type == 'group' || data.type == 'root'"
@click="addNewLayer(data)">
<i class="fal fa-layer-plus"></i>
<span>{{ $t("x_add_a_new_layer") }}</span>
</div>
<div class="edit-item" v-if="data.type == 'group' || data.type == 'root'"
@click="addFolder(data)">
<i class="fal fa-folder-plus"></i>
<span>{{ $t("x_add_folders") }}</span>
</div>
<div class="edit-item" v-if="data.type != 'root'" @click="deleteLayerFromTree(data)">
<i class="fal fa-trash-alt"></i>
<span>{{ $t("x_delete") }}</span>
</div>
</template>
</el-popover>
</span>
{{ data.title }}
</span>
</template>
</el-tree>
解决方法: 可以选择用一个< span >将整个< el-popover >包起来,给span加 一个 @click.stop,即可阻止冒泡文章来源地址https://www.toymoban.com/news/detail-847644.html
到了这里,关于el-tree与el-popover配合使用避免事件冒泡的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!