我有一个打开Popover
元素的按钮。在对话框中,我有两个按钮:Cancel
并且Sure
,当我单击其中一个按钮时,我想关闭对话框。我怎样才能做到这一点?
这是我的代码:
var vm = new Vue({
el:'#app',
data:function(){
return {
data:[
{
id:1,
name: 'jak',
age: 24
},
{
id:2,
name: 'irol',
age: 34
}
]
}
},
methods:{
edit(){},
remove(){
// how can i cancel the el-popover
},
otherClick(){
}
}
})
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
<script src="https://cdn.bootcss.com/element-ui/2.3.2/index.js"></script>
<div id="app">
<el-table :data="data" style="width:100%" border>
<el-table-column prop="id" label="id" ></el-table-column>
<el-table-column prop="name" label="Name" ></el-table-column>
<el-table-column prop="age" label="Age" ></el-table-column>
<el-table-column label="Action">
<template slot-scope="scope">
<el-button type="primary" class="mr-20" @click="edit(scope)">Edit</el-button>
<el-popover placement="top" trigger="click" title="Sure?">
<div class="btn-confirm">
<el-button type="text" size="mini" @click="otherClick">Cancel</el-button>
<el-button type="primary" size="mini" @click="remove(scope)">Sure</el-button>
</div>
<el-button type="danger" slot="reference">Delete</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
</div>