fix(user/index.vue): watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
style="margin-bottom: 20px"
|
||||
/>
|
||||
<el-tree
|
||||
ref="treeRef"
|
||||
ref="deptTreeRef"
|
||||
:data="deptOptions"
|
||||
:props="{ children: 'children',label: 'label'}"
|
||||
:expand-on-click-node="false"
|
||||
@@ -394,7 +394,7 @@ import {ElMessage, ElMessageBox, ElTree, ElForm} from 'element-plus'
|
||||
import {Search, Plus, Edit, Refresh, Delete, Lock} from '@element-plus/icons'
|
||||
import TreeSelect from '@/components/TreeSelect/Index.vue'
|
||||
|
||||
const treeRef = ref(ElTree)
|
||||
const deptTreeRef = ref(ElTree)
|
||||
const dataFormRef = ref(ElForm)
|
||||
const queryFormRef = ref(ElForm) // 变量名和绑定名ref一致
|
||||
|
||||
@@ -505,14 +505,16 @@ async function loadDeptOptions() {
|
||||
* 部门筛选
|
||||
**/
|
||||
watchEffect(() => {
|
||||
if (state.deptName) {
|
||||
const tree = unref(treeRef)
|
||||
tree.filter(state.deptName)
|
||||
}
|
||||
const deptTree = unref(deptTreeRef)
|
||||
deptTree.filter(state.deptName)
|
||||
}, {
|
||||
flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发,此属性控制在DOM元素更新后运行
|
||||
})
|
||||
|
||||
function filterDeptNode(value: string, data: any) {
|
||||
if (!value) return true
|
||||
if (!value) {
|
||||
return true
|
||||
}
|
||||
return data.label.indexOf(value) !== -1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user