美文网首页
解决请求unable to decode value问题

解决请求unable to decode value问题

作者: 前端阿良古 | 来源:发表于2018-11-08 18:02 被阅读0次

原因:

  • 传参含有例如- _ . ! ~ * ’ ( )% 等非法字符
  • 或不能接受中文?(网上有些看法是说页面编码是gb2312,后端接收是utf-8的,然后后端不能接收中文)

解决方案:

使用encodeURI函数,encodeURI() 函数是javascript全局函数,可把字符串作为 URI 进行编码。该方法不会对 ASCII 字母和数字进行编码,也不会对这些 ASCII 标点符号进行编码: - _ . ! ~ * ' ( ) 。

const htmlContent = editorState.toHTML(); // 这是一个富文本获取的长文本,其实就是一段长文本。。。
dispatch({
  type: 'educPublicNotice/save',
  payload: {
    ...fields,
     isNew,
    noticeId: editingKey,
    content: encodeURI(htmlContent), // 在传参的时候使用encodeURI()函数
    mediaIds: mediaIds.join(','),
    attachIds: attachIds.join(','),
    publicState,
  },
 });

相关文章

网友评论

      本文标题:解决请求unable to decode value问题

      本文链接:https://www.haomeiwen.com/subject/iiowxqtx.html