您的位置:首页 > Web前端 > JavaScript

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

2016-12-21 17:35 267 查看
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);
}
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: