如何在VUE js应用程序中使用es6类,以便将方法和数据绑定到一个类

问题描述

我正在寻找更好的解决方案,以便在VUE JS应用程序中使用ES6类。 我尝试在vue js应用程序中使用es6类。

class App {
    constructor(components) {
        this.el = "#app";
        this.data = {
            dialog : new Dialog()
        };

        this.watch = {
            "watcher": function (val) {
            }
        };

        this.methods = {
            get(){
                console.log('get');
            }
        }
    }
}

class Dialog {
    constructor(components) {
        this.title = "";
        this.content = "";
    }
}

var app = new Vue(new App());

方法和数据不属于该类。 我正在寻找一种解决方案,可以将数据直接绑定为属性,并像在JS类中那样使用方法

class App {
    constructor(components) {
        this.dialog = new Dialog();
    };

    get(){
         console.log('get');
    }
}

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)