更换功能而不是更换 [英] Replace function not replacing

查看:124
本文介绍了更换功能而不是更换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了一些文档来使用JavaScript替换功能,并没有改变任何东西。没有错误被抛出。知道我做错了什么吗?从XML检索变量 - 可能需要将其转换为字符串或其他内容?

I followed some documentation to use the JavaScript replace function and it's not changing anything. No errors are thrown. Any idea what I'm doing wrong? The variable is retrieved from XML - maybe it needs to be cast as a string or something?

for (var i = 0, iln = projects.length; i < iln; i++){
    var thumb = projects[i].get('thumb');
    thumb.replace("200.jpg", "640.jpg");
    console.log(thumb) //200.jpg not replaced
}

完整的拇指值应如下所示:

The full thumb value should look like this:

http://b.vimeocdn.com/ts/160/895/160895498_200.jpg

有没有更好的方法来查找和替换东西?

Is there a better way to find and replace things?

推荐答案

将值重新分配回 thumb

thumb = thumb.replace("200.jpg", "640.jpg");

这篇关于更换功能而不是更换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆