[英]How to pass string argument to javascript method
How to pass string argument to javascript method如何将字符串参数传递给 javascript 方法
my code我的代码
function paginatePage(getPath) {
alert("from pagenate page");
alert("home path initial " + getPath);
}
unable to get the alert message无法收到警报消息
when i called the method当我调用该方法时
[NSString stringWithFormat:@"paginatePage(%s)",getPath]
Probably just the quotes around the string literal missing?可能只是字符串文字周围的引号丢失了?
[NSString stringWithFormat:@"paginatePage('%s')",getPath]
You possibly need to qualify the string with quotes.您可能需要用引号限定字符串。
I don't know what that NSString syntax is, but something like:我不知道 NSString 语法是什么,但类似于:
[NSString stringWithFormat:@"paginatePage('%s')",getPath]
Your error does not come from this, because the code is 100% valid: this is how you pass a string argument to a function.您的错误并非由此而来,因为代码 100% 有效:这就是您将字符串参数传递给 function 的方式。
If you could provide some more code, maybe we could help you.如果您可以提供更多代码,也许我们可以帮助您。
Also, make sure no other function has the same name, or maybe it's how you called the function?另外,请确保没有其他 function 具有相同的名称,或者可能是您如何称呼 function?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.