小编Jus*_*tin的帖子

React Native 限制 TextInput 中的行数

如果将 multiline 设置为 true,React Native 将接受 TextInput 中的无限行,有 maxLength 但它只是限制最大字符数,那么如何设置 TextInput 的最大行数呢?

react-native

8
推荐指数
3
解决办法
2万
查看次数

React native http post得到了Json Parse错误:无法识别的标记'<'

当我尝试将数据从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)

php rest json ios react-native

5
推荐指数
1
解决办法
5580
查看次数

标签 统计

react-native ×2

ios ×1

json ×1

php ×1

rest ×1