1. js 获取map的键:
bosType: "353E3C6E" dynamic_Field37: false dynamic_Field39: bankAccountNumber: "45001604255060414843" bosType: "FB326E5E" id: "KggAAAC+kpD7Mm5e" name: "建行新城支行4843/一般户" number: "01.01-2014-0003" trusterEntries: [] [[Prototype]]: Object dynamicproperty7: "* 付款金额 为单据审批通过后支付金额;若存在预付款未" dynamicproperty8: "扣减金额需告知财务" id: "7OTwdUdOQKyV1sYTd2VonzU+PG4="
2. js 判断字符串中是否包含某个字符串
for(var key in mbos('entity').data.entry1[0]){ console.log(key); }
VM2290:2 parent VM2290:2 bosType VM2290:2 id VM2290:2 $$hashKey VM2290:2 dynamicproperty7 VM2290:2 dynamicproperty8 VM2290:2 dynamic_Field37 VM2290:2 dynamic_Field39
//str.indexOf("")的值为0时表示包含 ,-1表示不包含 var str = "hello Tara"; if(str.indexOf("Tara") == 0){ alert("Hi,Tara"); }
//例子:
for(var key in mbos('entity').data.entry1[0]){ if(!key.indexOf("dynamic_Field")){ console.log(key); } }
3.把字符串当做javascript代码执行
JavaScript规定,如果行首是大括号,一律解释为语句(即代码块)。如果要解释为表达式(即对象),必须在大括号前加上圆括号。
var a = 'global scope'; function b(){ var a = 'local scope' eval('console.log(a)'); //local scope } b();
例子:
//选择费用申请单 // debugger var fnumber = ""; for(var key in mbos('entity').data.entry1[0]){ if(!key.indexOf("dynamic_Field")){ var s = "mbos('entity').data.entry1[0]."+key; console.log(s); if(eval(s)){ fnumber = eval(s+".number"); } } }
标签:console,VM2290,dynamic,笔记,JS,key,var,entity From: https://www.cnblogs.com/lxpblogs/p/16665497.html