如果将 multiline 设置为 true,React Native 将接受 TextInput 中的无限行,有 maxLength 但它只是限制最大字符数,那么如何设置 TextInput 的最大行数呢?
当我尝试将数据从react-native发布到PHP API时,react-native显示错误:
Json Parse错误:无法识别的标记'<'
我通过邮递员使用标题类型'application/json'测试了PHP API,它运行正常,这里是反应原生代码,任何人都可以帮助我吗?提前致谢!
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
ActivityIndicatorIOS,
TextInput,
TouchableOpacity,
} from 'react-native';
const REQUEST_URL = 'http://localhost:8000/user';
export default class extends Component {
constructor(props) {
super(props);
}
_submit() {
fetch(REQUEST_URL, {
method: "POST",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
firstname: "Justin", lastname: "Robot"
})
})
.then((response) => response.json())
.then((responseData) => {
console.log(responseData.body);
})
.done();
}
render() {
return (
<View style={styles.container}>
<TouchableOpacity
style={styles.submitButton}
onPress={() => …Run Code Online (Sandbox Code Playgroud)