尝试替换字符串的一部分时出现“找不到函数替换”错误
"Cannot find function replace" errror when trying to replace part of a string
我需要一种方法,使用Google Apps Script将字符串的一部分替换为另一个字符串。我测试了以下内容,它起作用了:
function test(){
var value = 'https://plus.google.com/117520727894266469000';
var googleimageURL = googlePlus(value);
Logger.log('Returned Result: ' + googleimageURL);
}
function googlePlus(value){
var apiKey = ScriptProperties.getProperty('apiKey');
var re = 'http://'
var theURL = value;
Logger.log('Google+ is called: ' + value);
var replacingItem = 'https://';
var theURL = theURL.replace(re, replacingItem);
Logger.log('Google+ Values 2: ' + value + ' : ' + theURL + ' after ' + replacingItem);
return imageURL;
}
但是,当我嵌入到以下代码中时,它不起作用。知道吗?
//If a Google+ column was not specified,put a flag.
if (googleColumn && column == googleColumn) {
if (value == ""){
columns.push(nogoogleColumn);
values.push(flag);
var googleimageURL="";
} else {
var googleimageURL = googlePlus(value);
Logger.log('Returned Result: ' + googleimageURL);
}
}
脚本没有按照我的意愿工作。它似乎停在行:
var theURL = theURL.replace(re, replacingItem);
附加信息:谷歌通知我以下消息
在表单上提交
类型错误: 在对象 https://plus.google.com/117520727894266469000 中找不到函数替换。(第 536 行)表单提交
我发现了错误。这是类型错误。 第二个块中的value
不是"字符串",而第一个块是"字符串"。因此,要修复第二个块,我需要使用:
var value = value.toString();
在传递给googlePlus(value)
之前
相关文章:
- 气质的“nestRemoting()”有时可以'找不到关系
- 错误405:向Java控制器(Ajax)发送JSON时找不到POST方法
- 找不到模块捆绑包
- for循环中的javascript if语句找不到==
- 为什么JavaScript可以'找不到给定的InnerHTML并返回Cannot set property
- 失败:等待Protractor与页面同步时出错:“”;在窗口上找不到角度”;
- Babel编译错误:找不到模块核心js/library/fn/get迭代器
- [Vue warn]:找不到元素
- ngRoute找不到模板
- 未能加载,因为找不到支持的源.当播放HTML5音频元素时
- 因果报应-找不到模块:错误:无法解析模块'scs'
- Angular 2:在本地.json文件上找不到文件
- module.js在运行iron节点时找不到模块
- 放大弹出生成“;找不到文件”;YouTube视频的错误
- 我发现了一些只在移动设备上可见的垃圾邮件链接,我可以'找不到包含此垃圾邮件链接的脚本的位置
- Web 地址虚拟目录会断开外部 JavaScript 链接,因此找不到文件
- Meteor.js可以'找不到语义:ui包
- 找不到容器:goog.Disposable.instances _在为javascript工具使用泄漏查找器时出错
- Cufon 控制台错误,未替换字体.(引用错误:找不到变量:Cufon)
- 尝试替换字符串的一部分时出现“找不到函数替换”错误