[英]Include JS script into meteor
Let's say I have the following script in my old HTML file which I'd like to port to meteor 假设我的旧HTML文件中有以下脚本,我想将其移植到流星上
<script>
//recursivly go through JSON file
function recursiveGetProperty(obj, lookup, callback) {
for (property in obj) {
if (property == lookup) {
callback(obj[property]);
} else if (obj[property] instanceof Object) {
recursiveGetProperty(obj[property], lookup, callback);
}
}
}
</script>
I would like to include that under index.js 我想将其包含在index.js下
/client
index.html
index.js
I tried to wrap the script with Template.index.events{} but it doesn't seem to work for me. 我试图用Template.index.events {}包装脚本,但是它似乎对我不起作用。
Any help would be appreciated 任何帮助,将不胜感激
Don't use <script>
tag. 不要使用
<script>
标记。 Just paste your function on index.js
and you are good to go. 只要将您的函数粘贴到
index.js
,就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.