我正在使用这个组件https://element.eleme.io/#/en-US/component/popover
我需要传递正确的点击事件从一个按钮到另一个按钮,并显示弹出下转发按钮
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.8.2/lib/index.js"></script>
<div id="app">
<template>
<el-button @click="$refs.forward.click()">Click to forward</el-button>
<el-popover
placement="bottom"
title="Title"
width="200"
trigger="click"
content="this is content, this is content, this is content">
<el-button ref="forward" slot="reference">Click to activate</el-button>
</el-popover>
</template>
</div>
我已经通过$refs.forward.click()
传递了点击事件,但它不会触发弹出窗口。我是不是遗漏了什么?
发布于 2019-05-24 05:52:39
你在这里想太多了:
向data
添加一个名为visible
的新属性
visible: false
然后在click to forward
上修改一下
@click="visible = !visible"
最后,将其分配给popover的v-model
:
v-model="visible"
好了。
https://stackoverflow.com/questions/56282781
复制相似问题