我试图做的就是呈现状态'草稿'在H1标签上,它根本不会做到!它让我疯了。我做错了什么?
最初的H1标签我可以看到这个'是可见的,但第二对完全没有出现..
import React, { Component } from 'react';
import Header from '../components/Header'
import NewTodo from '../components/NewTodo'
import List from '../components/List'
class TodoContainer extends Component{
constructor(){
super()
this.state = {
todos: ['bathroom', 'kitchen', 'loungeroom'],
draft: 'READ ME!'
}
}
render(){
return (
<div>
<h1>I can see this</h1>
<h1>{() => this.state.draft}</h1>
</div>
)
}
}
export default TodoContainer
答案 0 :(得分:0)
你需要写这一行:
<h1>{this.state.draft}</h1>
而不是这一行:
<h1>{() => this.state.draft}</h1>