在 Meteor 中使用从“script src"执行的外部脚本 [英] Using external scripts in Meteor executed from "script src"

查看:48
本文介绍了在 Meteor 中使用从“script src"执行的外部脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站上使用一个脚本,我知道我必须将所有脚本与模板分开放在一个 .js 文件中.但是这次直接在脚本src里面执行脚本就不知道怎么做了:

I want to use a script on my web site and I know that I must put all scripts separated from the template in a .js file. But I don't know how to do it this time when the script is executed directly in the script src:

<script type="text/javascript" src="http://svenskfotboll.se/widget.aspx?scr=table&amp;ftid=39662&amp;b1=%23006bb7&amp;f1=%23ffffff&amp;b2=%23bfd4f3&amp;f2=%23000000&amp;b3=%23ffffff&amp;f3=%23000000&amp;b4=%23ececec&amp;bo=%23ffffff&amp;s=1"></script>

让它在 Meteor 中工作的最佳实践是什么?

What is the best practice to get it to work in Meteor?

推荐答案

使用 jQuery.getScript(): http://api.jquery.com/jquery.getscript/

Use jQuery.getScript(): http://api.jquery.com/jquery.getscript/

就你而言:

$.getScript( "http://svenskfotboll.se/widget.aspx?scr=table&amp;ftid=39662&amp;b1=%23006bb7&amp;f1=%23ffffff&amp;b2=%23bfd4f3&amp;f2=%23000000&amp;b3=%23ffffff&amp;f3=%23000000&amp;b4=%23ececec&amp;bo=%23ffffff&amp;s=1" );

您还可以指定成功或失败的回调(请参阅上面链接的文档).

You can also specify callback for success or failure (please see documentation linked above).

这篇关于在 Meteor 中使用从“script src"执行的外部脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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