如何将createAllocation.txt文件进行高效分配处理?
- 内容介绍
- 文章标签
- 相关推荐
本文共计156个文字,预计阅读时间需要1分钟。
创建资源分配.txt 文件中的函数 createAllocation(data) 如下所示:
javascriptcreateAllocation(data) { if (Array.isArray(data.input)) { let profile={}, P, inputs=data.input; const def={ id: '', name: 'noname', type: 'text', value: '', placeholder: '' }; Object.keys(data).forEach(item=> { if (item==='input') { inputs.forEach(input=> { profile[input.id]=def; }); } else { profile[item]=def; } }); }}
createAllocation.txtfunction createAllocation(data){ if (A.isArray(data.input)) { let profile = {}, P, inputs = data.input const def = { id: '', name: 'noname', type: 'text', value: '', placehold: '' } O.keys(data).forEach( item => { if (item!='input') profile[item] = data[item] }) return inputs.map( input => { P = _.extend( def, (input.props||input)) P.attr = { title: profile.title||P.title||'', desc: profile.desc||P.desc||'', className: (profile.itemClass||P.itemClass) ? 'inputItem '+(profile.itemClass||P.itemClass) : 'inputItem' } if (P.union){ P.target = { id: P.id, name: P.name, type: P.type, } } }) } return data }
本文共计156个文字,预计阅读时间需要1分钟。
创建资源分配.txt 文件中的函数 createAllocation(data) 如下所示:
javascriptcreateAllocation(data) { if (Array.isArray(data.input)) { let profile={}, P, inputs=data.input; const def={ id: '', name: 'noname', type: 'text', value: '', placeholder: '' }; Object.keys(data).forEach(item=> { if (item==='input') { inputs.forEach(input=> { profile[input.id]=def; }); } else { profile[item]=def; } }); }}
createAllocation.txtfunction createAllocation(data){ if (A.isArray(data.input)) { let profile = {}, P, inputs = data.input const def = { id: '', name: 'noname', type: 'text', value: '', placehold: '' } O.keys(data).forEach( item => { if (item!='input') profile[item] = data[item] }) return inputs.map( input => { P = _.extend( def, (input.props||input)) P.attr = { title: profile.title||P.title||'', desc: profile.desc||P.desc||'', className: (profile.itemClass||P.itemClass) ? 'inputItem '+(profile.itemClass||P.itemClass) : 'inputItem' } if (P.union){ P.target = { id: P.id, name: P.name, type: P.type, } } }) } return data }

