提交 5a737c6a 编写于 作者: T tinyu

fix:优化自定义下拉框

上级 2924ae86
<template> <template>
<div> <div>
<el-popover placement="bottom-start" width="200" trigger="click"> <el-popover placement="bottom-start" v-model="shwoPop" width="200" trigger="click">
<el-select slot="reference" ref="selectBox" :value="selectKey" multiple collapse-tags <el-select slot="reference" ref="selectBox" suffix-icon="el-close" :value="selectKey" multiple collapse-tags
placeholder="请选择" @visible-change="$refs['selectBox'].blur()" @remove-tag="delTag"> placeholder="请选择" @visible-change="$refs['selectBox'].blur()" @remove-tag="delTag">
<el-option label="1" value="a"></el-option> <el-option label="1" value="a"></el-option>
<template #suffix>AAAA</template>
</el-select> </el-select>
<div> <div>
<el-row> <el-row>
...@@ -37,6 +36,7 @@ export default { ...@@ -37,6 +36,7 @@ export default {
}, },
data() { data() {
return { return {
shwoPop:false,
checkValue: { checkValue: {
category1: [], category1: [],
category2: [] category2: []
...@@ -60,15 +60,33 @@ export default { ...@@ -60,15 +60,33 @@ export default {
selectKey(){ selectKey(){
return this.allcheck.map(v => v.value) return this.allcheck.map(v => v.value)
} },
}, },
mounted() { mounted() {
this.init()
}, },
methods: { methods: {
//初始化
init(){
if(this.$refs['selectBox']){
const iconDom = this.$refs['selectBox'].$el.querySelector('.el-input__suffix .el-input__icon');
const closeWatch = this.$watch('shwoPop',(val => {
const num = val ? 0 : 180;
iconDom.style.transform=`rotateZ(${num}deg)`
}))
this.$once('hook:beforeDestroy', () => {
closeWatch()
})
}else{
console.log('Not find ref of selectBox')
}
},
//删除标签 //删除标签
delTag(tag){ delTag(tag){
this.allcheck = this.allcheck.filter(v =>{ this.allcheck = this.allcheck.filter(v =>{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册