学习React(三)-使用React.createElement创建dom

import React from "react";

class CreateNode extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    return React.createElement(
      "div",
      { id: "headerRoot", className: "header-wrap", name: "添加属性" },
      "我是内容",
      React.createElement("p", {}, "我是p标签"),
      React.createElement(
        "p",
        {},
        "我是p2标签,我里面要添加其他元素了",
        React.createElement("span", { className: "spanStyle" }, "我是span标签")
      )
    );
  }
}

export default CreateNode;

你可能感兴趣的:(React,react.js,学习,javascript)