我有一个函数通过首先用RequireJS加载插件来调用jquery插件函数,问题是requirejs中的插件函数只有在我的函数已经返回后才会执行,所以hasMessageParent总是返回null。我真的很困惑,因为这之前工作正常,我不知道发生了什么变化和坏了。如何修复 myMsg 在继续之前设置为函数返回?
hasMessageParent: function() {
    var myMsg = null;
    var ctrl = '#myDiv';
    require(["my_msgcheck"], function() {
        // this gets executed after the return already happened, it returns true
        myMsg = $(ctrl).msg_check('hasMessage');
    });
    // this always returns null because the require jquery plugin function is executed after the return already happened
    return myMsg ;
},