lodash#toPath JavaScript Examples

The following examples show how to use lodash#toPath. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.js    From hzero-front with Apache License 2.0 7 votes vote down vote up
/**
 * 将 templates config 的值 设置到 头数据中
 */
export function dealConfig(templates) {
  forEach(templates, template => {
    forEach(template.config, attr => {
      const attrPath = toPath(attr);
      set(template, attrPath, {
        ...attr,
        [attrFlagField]: true,
        [attributeNameProp]: attrPath[attrPath.length - 1],
      });
    });
    forEach(template.fields, field => {
      forEach(field.config, attr => {
        const attrPath = toPath(attr);
        set(field, attrPath, {
          ...attr,
          [attrFlagField]: true,
          [attributeNameProp]: attrPath[attrPath.length - 1],
        });
      });
      delete field.config;
    });
    delete template.config;
  });
}