【问题标题】:materialize modal popup auto initialize not working in vue js物化模态弹出自动初始化在vue js中不起作用
【发布时间】:2018-02-16 01:57:05
【问题描述】:

Materialize modal popup 在 onclick 函数中正常工作,但在mounted() 或 created() 中不工作

     testingmodel:function(){ 
             $('#firstlogintour').modal('open'); 
        }

    mounted() { 
        this.testingmodel(); 
    },

【问题讨论】:

    标签: laravel vue.js material-design materialize


    【解决方案1】:

    我已经从 VueJs 更新事件中调用了相同的函数

    updated() 
    { 
                this.testingmodel(); 
            },
    

    ** 但是你必须通过在调用函数上使用 try catch 来避免错误

    testingmodel:function(){ 
                 $('#firstlogintour').modal('open'); 
            }
    

    Vue 更新场景:

    此函数将在函数或方法加载时调用,没有失败或任何错误。

    【讨论】:

    • 发生这种情况是因为安装后,您的“#firstlogintour”元素尚未呈现。我不知道原因。但是随后,其他的东西被初始化,然后,模态可用。您可以使用this.$nextTick(()=>this.testingmodel()) 实现相同的效果。但这无论如何都不是你正在做的事情。如果您想等到它存在,请使用观察者
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多