mirror of
https://github.com/openharmony/third_party_jsframework.git
synced 2026-07-19 14:33:33 -04:00
Signed-off-by: lixingchi1 <lixingchi1@huawei.com>
This commit is contained in:
@@ -145,7 +145,7 @@ export default class Vm {
|
||||
`'_innerInit' lifecycle in Vm(${this._type}) and mergedData = ${JSON.stringify(mergedData)}.`
|
||||
);
|
||||
this.$emit('hook:_innerInit');
|
||||
this._data = (this.data !== undefined ? this.data : typeof data === 'function' ? data.apply(this) : data) || {};
|
||||
this._data = (typeof data === 'function' ? data.apply(this) : data) || {};
|
||||
this._shareData = (typeof shareData === 'function' ? shareData.apply(this) : shareData) || {};
|
||||
this._descriptor = options._descriptor;
|
||||
if (global.aceapp && global.aceapp.i18n && global.aceapp.i18n.extend) {
|
||||
@@ -449,9 +449,9 @@ export default class Vm {
|
||||
return;
|
||||
}
|
||||
if (key.indexOf('.') !== -1) {
|
||||
_proxySet(this.data, key, value);
|
||||
_proxySet(this._data, key, value);
|
||||
}
|
||||
set(this.data, key, value);
|
||||
set(this._data, key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,7 +463,7 @@ export default class Vm {
|
||||
Log.warn(`Invalid parameter type: The type of 'key' should be string, not ${typeof key}.`);
|
||||
return;
|
||||
}
|
||||
del(this.data, key);
|
||||
del(this._data, key);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -659,11 +659,11 @@ export default class Vm {
|
||||
* Data of this Vm.
|
||||
* @type {*}
|
||||
*/
|
||||
public get data() {
|
||||
public get __data() {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public set data(newData: any) {
|
||||
public set __data(newData: any) {
|
||||
this._data = newData;
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ export function bindPageLifeCycle(vm: Vm, element: Element): void {
|
||||
return vm.$emitDirect(`hook:${type}`, saveData);
|
||||
}
|
||||
function handleNewRequest(data: any) {
|
||||
Object.assign(vm.data, data);
|
||||
Object.assign(vm.__data, data);
|
||||
return vm.$emitDirect(`hook:${type}`);
|
||||
}
|
||||
});
|
||||
@@ -269,8 +269,8 @@ export function watch(vm: Vm, data: string, callback: ((...args: any) => any) |
|
||||
*/
|
||||
export function initPropsToData(vm: Vm): void {
|
||||
vm.props.forEach(prop => {
|
||||
if (vm.data) {
|
||||
vm.data[prop] = vm[prop];
|
||||
if (vm.__data) {
|
||||
vm.__data[prop] = vm[prop];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -203,9 +203,9 @@ describe('api of communication between vm and data methods', () => {
|
||||
doc.destroy();
|
||||
const detail = { aaa: 1 };
|
||||
vm.$set('test.aaa', detail);
|
||||
expect(typeof vm.data['test.aaa']).eql('object');
|
||||
expect(typeof vm.__data['test.aaa']).eql('object');
|
||||
vm.$delete('test.aaa');
|
||||
expect(typeof vm.data['test.aaa']).eql('undefined');
|
||||
expect(typeof vm.__data['test.aaa']).eql('undefined');
|
||||
});
|
||||
|
||||
it('$watch', () => {
|
||||
|
||||
Reference in New Issue
Block a user