const App = ({todos, actions}) => (
<p>
<Header addTodo={actions.addTodo} aaa/>
<MainSection todos={todos} actions={actions} />
</p>
)
这是父组件,里面有个Header是自定义组件,其中有个自定义属性是aaa.
这个aaa是我随手写的,也未在其他地方声明过。
然后我在Header里面,console.log出aaa,为啥是个true?

export default class Header extends Component {
static propTypes = {
addTodo: PropTypes.func.isRequired
}
render() {
console.log(this.props)//值为Object {aaa: true}
return (
<header className="header">
<h1>todos</h1>
<TodoTextInput newTodo
placeholder="What needs to be done?" />
</header>
)
}
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在
html5中,布尔属性可以缩写,你的写法相当于类似在表单中
打印出来没有addTodo属性吗