无状态函数function,传参数时,当少数参数参时
但多个参数时怎么使用es6的…props怎么传的参数,然后在函数中拿到这个props里的key
换种方式问—
function Input({ label, name, value, ...props }, { defaultTheme }) {
const { theme, autoFocus, ...rootProps } = props
return (
<label
htmlFor={name}
children={label || defaultLabel}
{...rootProps}
>
<input
name={name}
type="text"
value={value || ''}
theme={theme || defaultTheme}
{...props}
/>
)}
这个函数在调用时怎么传参