Meteor 1.2.1 版本 服务器代码中的 Meteor.method({}) 不起作用
Meteor 1.2.1 version Meteor.method({}) inside server code does not work
客户端单击sendlogmessage
调用事件,但服务器端程序内的方法不调用sendlogmessage
。
console.log
没有用。谁能帮我找到答案?
if (Meteor.isClient) {
Template.mytemplate.events({
"click": function () {
Meteor.call('sendLogMessage');
}
})
}
if (Meteor.isServer) {
Meteor.methods({
'sendLogMessage': function(){
console.log("Hello world");
}
});
}
你的代码正在工作。您只需要指定要单击的应触发事件的元素。像这样:
HTML
<template name="mytemplate">
<p id="clicable">Click me!</p>
</template>
JAVASCRIPT
Template.mytemplate.events({
"click #clicable": function() {
Meteor.call('sendLogMessage');
}
})
或
HTML
<template name="mytemplate">
<p class="clicable">Click me!</p>
</template>
JAVASCRIPT
Template.mytemplate.events({
"click .clicable": function() {
Meteor.call('sendLogMessage');
}
})
相关文章:
- Meteor-添加用户自定义字段的方法不起作用
- window.location.href 在 Meteor 中不起作用
- Meteor中的ExecCommand不起作用
- MongoDB & Meteor - 推送到嵌套数组的查询不起作用,没有抛出错误
- Meteor 1.2.1 版本 服务器代码中的 Meteor.method({}) 不起作用
- Meteor.js email.send 在尝试发送给用户数组时不起作用
- URL 解析在 Meteor.startup 中不起作用
- 从 Meteor 服务器插入到数据库不起作用
- 使用 Meteor 自定义 Github 登录不起作用
- CytoScape.js和Meteor简单的例子不起作用
- MeteorJS-click.increment函数不起作用(您的第一个Meteor应用程序)
- 在Meteor中实体化导航栏不起作用
- Meteor-dons'中的查询子文档;不起作用
- Meteor发布和订阅不起作用
- 我想用Meteor.setInterval()来更新时间模板,它不起作用
- 由于选择器不起作用,json中包含日期的Meteor db.find
- Meteor React组件onClick事件在IE中不起作用
- setState在React和Meteor的UI更改中不起作用
- bootstrap3中的侧边栏在Meteor.js中不起作用
- Router.go()在Meteor js中不起作用