首页 > 其他分享> > 在element-ui 中使用form表单中的input框,点击input框弹出一个对话框,将值传给form表单的input中,如果没有使用 this.$set("对象",“键”,
在element-ui 中使用form表单中的input框,点击input框弹出一个对话框,将值传给form表单的input中,如果没有使用 this.$set("对象",“键”,
作者:互联网
父组件
<el-form ref="dataForm" :rules="rules" :model="form" label-width="100px"> <el-form-item label="选择上级" prop="superior"> <!-- v-if="textMap[dialogStatus] =='新增'" --> <el-input v-model="form.superior" @focus="handleSelect" placeholder="请输入内容"></el-input> </el-form-item> <el-form-item :label="typeRowName + '名称'" prop="fondsName"> <el-input :placeholder="'请选择' + typeRowName + '名称'" v-model="form.fondsName" class="input-with-select"> <el-input v-model="form.fondsName" @focus="handleSelect" placeholder="请输入内容"></el-input> </el-input> </el-form-item> </el-form> <select-user :user-config="userConfig" @submit="handleSubmit"></select-user> <script> import selectDepartmentTree from './components/selectDepartmentTree' export default { data(){ form: { superior:'', fondsName: '' }, rules: { superior:[{ required: true, message: '不能为空', trigger: 'change' }], fondsName: [ { required: true, message: '名称不能为空!', trigger: 'blur' }, { min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur' } ], }, userConfig:{ visible:false }, }, components:{ selectDepartmentTree }, method:{ handleSelect(){ this.userConfig.visible = false }, handleSubmit(val){ this.$set("form",“superior”,val) } } } </script> 子组件 <template> <buttom @click="add">添加</buttom> </template> <script> export default{ method:{ add(){ this.$emit("handleSubmit", 靓仔) } } } </script>标签:superior,form,表单,selectDepartmentTree,trigger,input,message 来源: https://www.cnblogs.com/G-Lose/p/15260792.html