Commit 23065a3a authored by rockyl's avatar rockyl

修复DataCenter获取真实数据的问题(避免eval)

parent ce931af5
...@@ -66,6 +66,18 @@ export default class DataCenter extends EventEmitter{ ...@@ -66,6 +66,18 @@ export default class DataCenter extends EventEmitter{
* @param expression * @param expression
*/ */
public parse(type: string, expression: string) { public parse(type: string, expression: string) {
return window['eval'](`(console.log(this);this.store['${type}'].${expression})`) let node = this.store[type];
let segments = expression.split('.');
while(segments.length > 0){
const segment = segments.shift();
if(!node){
console.warn(`can not get ${segment} on ${segment}`);
break;
}
node = node[segment];
}
return node;
//return eval(`(this.store['${type}'].${expression})`);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment