JS中含有特殊字符的处理

js链接中含有+号特殊字符处理,不能传到后台

用encodeURIComponent将特殊字符转义后即可。
实际用例:
export function publishNotice(contents,title) {
contents=encodeURIComponent(contents);
const data = {
title,
contents
}
console.log(“发布的内容:”+contents);
console.log(“title=”+title)
return fetch({
url: ‘/backManger/fmkj/HcNotices/publishNotice’ + getParams(data),
method: ‘post’
});
}

这里写图片描述

猜你喜欢

转载自blog.csdn.net/huangshuangda/article/details/82258056
今日推荐