WebApp【公共组件库】@前端(For Git Submodule)
Tevin
2020-12-09 607ca3a52f33a14e83533b5f8c34252016c819c3
允许 polit 在 createOptions 时,插入 data
1 files modified
15 ■■■■ changed files
bases/Pilot.js 15 ●●●● patch | view | raw | blame | history
bases/Pilot.js
@@ -12,7 +12,7 @@
        return {};
    }
    createOptions() {
    createOptions(dataAdd) {
        const options = {
            methods: {},
        };
@@ -21,7 +21,18 @@
                return;
            }
            if (/^\$/.test(name)) {
                options[name.replace('$', '')] = this[name];
                if (name === '$data' && typeof dataAdd !== 'undefined') {
                    // 当有传data值进来,初始值必须带data中的字段
                    const dataOrig = this.$data();
                    options.data = () => {
                        return {
                            ...dataOrig,
                            ...dataAdd,
                        }
                    }
                } else {
                    options[name.replace('$', '')] = this[name];
                }
            } else {
                options.methods[name] = this[name];
            }