自定义面板中的消息函数里如何使用Vue的data里面的变量

  • Creator 版本: 2.4.3

  • 目标平台: 编辑器

在自定义面板中收到消息后,请问如何传递到Vue的data里面的变量呢?

例如:

Editor.Panel.extend({

style: ...,
template: ...,
ready() {
    new window.Vue({
        el: this.shadowRoot,
        data: {
            message: 'Hello World',
        },
   });
},
messages: {
    'greeting': function (event, question) {
         请问这里如何把question更新到vue的message变量中呢?
         以及这里如何使用vue的变量和函数呢?
         谢谢!!
    }
},

});

let plugin = null;

Editor.Panel.extend({
    style: ...,
    template: ...,

    ready() {
        plugin = new window.Vue({
            el: this.shadowRoot,
            data: {
                message: 'Hello World',
            },
            methods:{
                hello(){
                    console.log('hello');
                }
            }
        });
    },
    messages: {
        'greeting': function (event, question) {
            plugin.message=question;
            plugin.hello();
        }
    },
});

谢谢,我目前也只能想到这样用了。我以为会有其他什么特殊的方法:grinning: