我需要知道如何在Meteor中使用Jquery框架。我使用Jquery按鈕事件做了一個簡單的例子,但得到了一些錯誤。我對這個錯誤沒有任何想法。所以請看下面的代碼,並告訴我該怎麼做?在流星中使用jquery的按鈕事件問題?
HTML代碼:
app.html
--------
<head>
<title>app</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
{{> menu}}
</body>
menu.html
---------
<template name="menu">
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</template>
JS代碼:
if (Meteor.isClient)
{
Template.menu.events
({
$(document).ready(function()
{
$("button").click(function()
{
$("p").hide();
});
});
});
}
錯誤消息:
1)這是編譯錯誤,2)不要手動加載jquery - meteor包括它,3)不要在流星應用中使用'$(document).ready' - 用事件地圖替換此代碼。 –