Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当用户在react本地android设备中输入印度卢比符号(₹)或其他货币符号时,他们会将其作为"₹&引用;_Android_React Native_Axios - Fatal编程技术网

当用户在react本地android设备中输入印度卢比符号(₹)或其他货币符号时,他们会将其作为"₹&引用;

当用户在react本地android设备中输入印度卢比符号(₹)或其他货币符号时,他们会将其作为"₹&引用;,android,react-native,axios,Android,React Native,Axios,当用户键入货币符号(如印度卢比)时₹ 在android输入字段中,单击submit,然后发送到服务器的值为–而不是₹ 在请求中 但当我在发出axios api请求之前打印控制台时,它正在打印₹ 在控制台中正确输入 因此,我认为在发出axios请求时可能需要进行一些编码 如果有人知道如何用react native发送特殊符号,请帮助我 我的示例代码使用fetch let data = { message: this.state.internalValue, }; fe

当用户键入货币符号(如印度卢比)时₹ 在android输入字段中,单击submit,然后发送到服务器的值为–而不是₹ 在请求中

但当我在发出axios api请求之前打印控制台时,它正在打印₹ 在控制台中正确输入

因此,我认为在发出axios请求时可能需要进行一些编码

如果有人知道如何用react native发送特殊符号,请帮助我

我的示例代码使用fetch

 let data = {
      message: this.state.internalValue,
    };
    fetch('https://www.myapi.com', {
      method: 'POST',
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json'
      },
      body:JSON.stringify(data)
    });
使用axios

axios.post("https://www.myapi.com", data)
      .then(response => {
     
      })
      .catch(error => {
       
      });
在axios中使用表单数据

   let jsondata = {
      message: this.state.internalValue,
    };

    var axios = require('axios');
    var FormData = require('form-data');
    var data = new FormData();
    data.append('data', true);

    var config = {
      headers: {
        'Content-Type': 'application/json; charset=utf-8',
       
      },
    };

    axios.post('https://myapi.com',jsondata,config)
      .then((response) => {
     
      })
      .catch(error => {
    
      });
当前行为

当我在android studio profiler中调试请求时,值是这样发送的,而不是₹.

{
"message": "₹"
}

试试看
用于formdata

const formData = new FormData();
    formData.append("data", true);

    const config = {
      headers: {
        "Content-Type": "multipart/form-data; charset=utf-8;"
      }
    };

    axios.post(URL, formData, config).then(
      response => {
        console.log({ response });
      },
      error => {
        console.log({ error });
      }
    );
用于正常提取

fetch(uri, {
    headers:{
      contentType: "application/json; charset=utf-8",
    }
  })
  .then(
  (response) => {
    var contentType = response.headers.get('content-type')
    console.warn(contentType)
      return response.json()
    }
    ).then((myJson) => {
      console.log(JSON.stringify(myJson));
    }).catch((err) => {
      console.log(err)
    })
  }

我尝试使用axios时出现网络错误。请分享,我是这样尝试的。1.使用fetch let data={message:this.state.internalValue,};fetch(“”,{method:'POST',headers:{Accept:'application/json','Content Type':'application/json'},body:json.stringify(data)});2.使用axios.post(“,data).then(response=>{}).catch(error=>{});