默认展开节点属性 : default-expand-all
本地有完整的树形结构数据,成为展开节点条件,数据里面有:children
懒加载模式,数据里面有: hasChildren: true
这两个属性还可以通过 tree-props 属性自定义:
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
默认展开节点属性 : default-expand-all
本地有完整的树形结构数据,成为展开节点条件,数据里面有:children
懒加载模式,数据里面有: hasChildren: true
这两个属性还可以通过 tree-props 属性自定义:
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
在写新增编辑页面的时候,有些情况需要把页面的data全部初始化还原到新增的时候,
Object.assign(this.$data, this.$options.data());
template代码:
<el-form-item label="目标用户及数据需求描述" class="project-desc project-targetUser" prop="targetUser" :rules="targetRequired ? addFormRules.targetUser : addFormRules.targetUserFalse" >
通过:rules来控制启用哪个校验规则
script代码:
targetUser: [ { required: true, message: '请输入目标用户及数据需求描述', trigger: 'blur' } ], targetUserFalse: [ { required: false, message: '请输入目标用户及数据需求描述', trigger: 'blur' } ],
如果有选项联动,选择其中一个选项,清除联动项的值并初始化选项的值,会触发form表单的blur事件和校验规则。
kindId: [ { required: true, message: '请选择设备小类', trigger: 'change' } ],
可以在 $nextTick 用单独清除表单验证项来清理弹出的错误提示:
this.$nextTick(()=>{ this.$refs.reportForm.clearValidate(['name']) })
clearValidate() 参数接收数组
//为空: array == undefined || array.length <= 0 (顺序不能调换) //不为空: array !==undefined && array.length > 0