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