例如,这段代码:
React.createElement(
"h1",
null,
"Shopping List for ",
props.name
),
空值代表什么,或者它可以用来做什么?
最佳答案
来自 the React docs :
createElement()
React.createElement( type, [props], [...children] )
Create and return a new React element of the given type. The type argument can be either a tag name string (such as
'div'
or'span'
), a React component type (a class or a function), or a React fragment type.
文档没有明确提到的是 props
应该是一个对象。例如:
{
click: dothing,
className: 'myClass'
}
如果您需要指定子项而不是属性,则可能是 {}
或 null
关于reactjs - React.createElement() 可以传入哪些参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53695649/