我正在使用social share plugin Cordova 将短信分享到特定号码。
<a
class = "lft"
onclick="window.plugins.socialsharing.shareViaSMS('My cool message', 7767051447, function(msg) {console.log('ok: ' + msg)}, function(msg) {alert('error: ' + msg)})">
<img src="sms.png" alt="info" height="8%" align="middle">
</a>
它应该传递一个包含电话号码的变量phone_no
,而不是传递号码。我如何实现这一目标?
最佳答案
如果您确定应该传递变量而不是数字。然后你就可以这样做。
<script>
var phone_no="7767051447";
function sendN()
{
window.plugins.socialsharing.shareViaSMS('My cool message', phone_no, function(msg) {console.log('ok: ' + msg)}, function(msg) {alert('error: ' + msg)});
}
</script>
并在该 anchor 标记的 onclick 中调用 sendN() 。 顺便说一句,在您的代码中,您应该将您的号码放在引号内。它会起作用的。
关于javascript - 使用 cordova 社交共享插件发送带有变量的短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39666454/