React 组件根据数据动态渲染

数据驱动的UI界面

import React from 'react';
import * as componentLib from './components/index';
import {dataMap} from './data/dataMap';

function renderDataMap() {
    console.log(dataMap);
    const dom = dataMap.map((item, index) => {
        if(!(item.componentName && componentLib[item.componentName])){
            return null;
        }
        const TagName = componentLib[item.componentName];
    
        return (
        
        );
  });
  return dom;
}

export default renderDataMap;

你可能感兴趣的:(Javascript,前端工程化)