中文乱码问题
发布于 5 年前 作者 shenming 18536 次浏览 来自 问答

小程序的开发环境,中文显示一切都正常,而使用手机预览时,中文确实乱码,请问怎么解决

使用的wx.request的get请求服务器的数据,返回的中文也是正常显示。

10 回复
  1. android是否有问题?

  2. 有问题的接口可否贴出来,我们访问试试

PHP输出是中文乱码

添加了header(“Content-Type:text/html; charset=utf-8”);这个也没有效果

android没有问题

手机换了两个试了

好的,谢谢

编码是编码问题,问题是真没有办法怎么解决了。。。。

解决了吗 ?

__接口URL__是可否贴出来看看

https://www.ybhtest.club/1.php  返回都是正常显示的,测试环境也正常,就是手机预览就是乱码了

Page({
  data: {
    // threads: [],
  },
  onLoad: function () {
    var that = this;
    wx.request({
      url: ‘https://www.ybhtest.club/1.php’,
      header: {
        // “content-type”: “applciation/json”,
       // “charset”: “utf-8”
      },
      method: “GET”,
      success: function (res) {
        //console.log(res.data);
        that.setData({
          threads: res.data
        })
      },
      fail: function (err) { console.log(err) },
      complete: function () { }
    })
  }
})

[root@VM_106_230_centos ~]# rpm -qa |grep httpd
httpd-2.4.12-1.el6.x86_64

回到顶部