js传递参数中包含+号时的处理方法

Posted 張暁磊

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js传递参数中包含+号时的处理方法相关的知识,希望对你有一定的参考价值。

encodeURI(url).replace(/\+/g, ‘%2B‘)

例子:

$scope.getAnesthesiawaystatistical = function (annual, anesthesiaMethodRep) {
var Anesthesiurl = "/api/v1/AnesthesiAwayStatistical/GetAnesthesiAwayStatisticalCount?anesthesiaMethodRep=" + "‘" + anesthesiaMethodRep + "‘" + "&annual=" + annual;
alert(encodeURI(Anesthesiurl).replace(/\+/g, ‘%2B‘));
$http.get(encodeURI(Anesthesiurl).replace(/\+/g, ‘%2B‘)).success(function (data) {

if (data.has_val) {
$scope.AnesthesiAwayStatisticalList = data.result;

console.log($scope.AnesthesiAwayStatisticalList);
}
});
}












以上是关于js传递参数中包含+号时的处理方法的主要内容,如果未能解决你的问题,请参考以下文章

post 传递参数中包含 html 代码解决办法,js加密,.net解密

在js传递参数中含加号(+)的处理方式

如何传递文件中包含的命令行参数并保留该文件的名称?

Uipath 调用Vbs(含传递参数和返回值)

如何在任意方法名称上使用的 @Timed 注释中包含方法参数

JS怎么样调用IOS并且传递参数?