The problem of refs in vue

clipboard.png

clipboard.png

because there is an el-dialog on the outside. You can"t get this.$refs.form,

it is possible to do this in the previous demo vue-admin-master

I wonder if it is the vue version update or the ElementUI version update that has this problem?

who has encountered this problem?

Apr.13,2022

m-oder is another component, go to the internal operation of the component


  1. m-order is a subcomponent or global component of orders .
  2. The content inside the
  3. component is filled into the component's slot, but the vue pursues where it is compiled, and the scope is there, so the scope of the slot content is in the orders component.

because you say this.$refs cannot get the form component instance, I judge that you execute this statement within the m-order or el-dialog component instance, which of course cannot be obtained. You need to call this.$refs.form in the orders instance to get it. If you want to get it in other components, you need to find the relationship between the current component and the orders component. For example, a parent-child relationship component can use the this.$parent.$refs attribute. If orders is the root component, you can use this.$root.$refs . Wait.

the above is for reference only. There is no actual test. In my experience, it should be so. If there is anything wrong, you are welcome to correct it.


another: you can add this.$refs ['editForm'] .clearValidate () to addOrUpdateUser, and add
clearValidate () {
this.$refs [' form'] .clearValidate ();
},
to remove the previous check information


this.$nextTick(() => {
    ...
})
.
Menu