这是我的React Web Hook示例:
import SerializedSwift
class User: Serializable {
@Serialized
var name: String
@Serialized("globalId")
var id: String?
@Serialized(alternateKey: "mobileNumber")
var phoneNumber: String?
@Serialized(default: 0)
var score: Int
required init() {}
}
// Inherited object
class PowerUser: User {
@Serialized
var powerName: String?
@Serialized(default: 0)
var credit: Int
}
现在我的改编不适用于本机反应,在表单部分使用什么?
function App() {
const [value, setValue] = useState('...')
const [name, setName] = useState('')
return (
<div>
<form onSubmit={e=>{
e.preventDefault()
if(!value.length) { return false }
setName(value)
}}>
<input type="text" value={value} onChange={e => setValue(e.target.value)}></input>
</form>
<p>mi llamo {value}</p>
<p> name : {name}</p>
</div>
)
}
export default App;
那么如何修改我上面的代码以在本机上工作?欢呼
答案 0 :(得分:1)
React-native中的onChangeText
onChangeText = {文本=> setValue(文本)}