Search code examples
vue.jselement-ui

How to render el-dialog before the first popup?


If the el-dialog has not opened before,elements under el-dialog cannot be retrieved using this.$refs as elements has not rendered.
I want to know how to render el-dialog but not show it because I need to initialize something in el-dialog.


Solution

  • You can use vm.$nextTick( [callback] )

    Example

    in methods

    OpenDialog() {
    
    this.dialogFormVisible = true; // your dialog toggle variable
    
        this.$nextTick(() => {
         
         // some action or your this.$refs will here
        
        });
    },
    

    Reference https://v2.vuejs.org/v2/api/#vm-nextTick