Skip to content

Commit

Permalink
fix(okam-core): fix ant component prop data observe
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhy committed Nov 9, 2018
1 parent 25b8eab commit c061f88
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/okam-core/src/extend/data/observable/ant/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @file Make component support data operation like Vue for ant mini program
* @author [email protected]
*/

'use strict';

import observable, {setPropDataKey} from '../index';

setPropDataKey('props');

export default observable;
18 changes: 17 additions & 1 deletion packages/okam-core/src/extend/data/observable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import ComputedObserver from './ComputedObserver';
import nextTick from './nextTick';
import {getSetDataPaths} from './setData';

/**
* The component property data key
*
* @type {string}
*/
let propDataKey = 'data';

/**
* Make computed props observable
*
Expand Down Expand Up @@ -56,7 +63,7 @@ function makePropsObservable(ctx) {
return;
}

let observer = new Observer(ctx, ctx.data, null, true);
let observer = new Observer(ctx, ctx[propDataKey] || {}, null, true);
let propsObj = {};

Object.keys(props).reduce((last, item) => {
Expand Down Expand Up @@ -125,6 +132,15 @@ function initProps(ctx, isPage) {
});
}

/**
* Set the component property data key
*
* @param {string} key the prop data key
*/
export function setPropDataKey(key) {
key && (propDataKey = key);
}

export default {
component: {

Expand Down

0 comments on commit c061f88

Please sign in to comment.