帖子
帖子
用户
博客
课程
显示全部楼层
1
帖子
0
勋章
6
Y币

[其他] ajax 回调数据怎样去掉反斜杠\

[复制链接]
发表于 2018-5-13 00:12:14
api.ajax({
        url: 'https://d.apicloud.com/mcm/api/user/' + userInfo.userId,
        method: 'get',
        headers: {
            "X-APICloud-AppId": "A6070164598639",
            "X-APICloud-AppKey": appKey,
            "Authorization": userInfo.id
        }
    }, function(ret, err) {
        if (ret) {
            //alert(JSON.stringify(ret));
            fnUpdateLocalAvatar(ret);
        } else {
            alert(JSON.stringify(err));
        }
    });
}

// 更新头像显示
function fnUpdateLocalAvatar(data_) {
    if (!data_.avatar) {
        return;
    }
    var icon = $api.byId('icon');
    api.imageCache({
        url:data_.avatar.url          此处出错!!!回传函数data_中包含反斜杠\,
    }, function(ret, err) {
        if (ret) {
            icon.style.backgroundImage = 'url(' + ret.url + ')';
        } else {
            api.toast({
                msg: '获取头像失败',
                duration: 2000,
                location: 'bottom'
            });
        }
    });
}

54
帖子
2
勋章
1538
Y币
可以尝试一下将\转换为/
1
帖子
0
勋章
6
Y币
请问怎样把\反斜杠去掉,用什么方法
54
帖子
2
勋章
1538
Y币
用js里面的
replace
34
帖子
5
勋章
2996
Y币
您需要登录后才可以回帖 登录

本版积分规则