【发布时间】:2015-04-03 08:12:07
【问题描述】:
我正在关注Meteor 上的官方教程。我们正在将一个事件附加到一个模板(第 4 步)。
HTML
<form class="new-task">
<input type="text" name="text" placeholder="Type to add new tasks" />
</form>
JS
Template.body.events({
"submit .new-task": function (event) {
var text = event.target.text.value;
我收到建议添加一个 console.log(event) 来检查事件的所有属性。当我在 Chrome 控制台中添加 console.log(event) 时,我可以看到一个带有很多属性的 jQuery 事件树,但我似乎无法对存储在文本变量中的属性进行罚款。
我也尝试过 console.log(event.target) 和 console.log(event.target.text) 但都没有给我一个属性树和 console.log(event.target.text.value) 只是日志控制台的期望值。
我必须执行哪个 console.log(?) 才能找到 event.target.text.value 的路径?或者在 Chrome 控制台中看不到这个?
【问题讨论】:
标签: events meteor properties