小编Jac*_*eid的帖子

流星:"模板助手中的异常"

我在Meteor中运行了一个基本的后期流,从Posts集合中提取.模板由以下模板助手提供,该助手可以进入集合:

    Template.postStream.helpers({
        /* Supplies posts collection to the client
        *  view. */
        postsStream: function(){
            var loggedUser = Meteor.user();
            return Posts.find({ userID: loggedUser._id });
        },

    });
Run Code Online (Sandbox Code Playgroud)

帮助器似乎一切正常,帖子按预期显示.但是,我在控制台中得到了这个模糊的错误,我无法弄清楚如何清除它: Exception in template helper: postsStream@http://localhost:3000/client/views/stream/post-stream.js?37c902af708ff817888efc24c4e45f352cfb6884:6:41

字符6:41对应于loggedUser._id字符串的中间位置.这是怎么回事?

meteor meteor-blaze

3
推荐指数
1
解决办法
912
查看次数

Meteor.user()只返回_id和用户名

使用accounts-passwordaccounts-ui模块创建用户后,当我Meteor.user()在控制台中调用时,我没有获得完整的配置文件,只有_idusername,即使文档上有更多内容,如createdAt记录.

如果我使用这些模板,则会出现同样的问题:

<template name="user_list">
    <div class="user-list">
    <h1>Users</h1>
        <ul>
        {{#each allUsers}}
            {{> user_item}}
        {{/each}}
        </ul>
    </div>
</template>

<template name="user_item">
    <li class="user-item">
        <p><b>{{username}}</b></p>
        <p>Created: {{createdAt}}</p>
    </li>
</template>
Run Code Online (Sandbox Code Playgroud)

......由这个助手支持:

Template.user_list.helpers({
  allUsers: function () {
    return Meteor.users.find({});
  }
});
Run Code Online (Sandbox Code Playgroud)

在这种情况下,user_list模板很好地迭代用户,并显示用户名,但createdAt帮助程序失败,即使我通过meteor mongo记录确实存在.我没有删除自动发布; 我的设置仍然完全打开.为什么我无法访问其余的用户记录?

meteor meteor-accounts

1
推荐指数
1
解决办法
1600
查看次数

React事件处理程序中的event.target null

给出以下代码:

var
  React = require("react")
;

class ControlText extends React.Component {
  constructor(props){
    super(props);
    this.state = {
      value: ""
    };
  }

  update() {
    console.log(event);
    this.setState({value: event.target.value});
  }

  render() {
    console.log(this.state);
    var value = this.state.value;
    return <input type="text" value={value} onChange={this.update.bind(this)} />
  }
}

module.exports = ControlText;
Run Code Online (Sandbox Code Playgroud)

每次我登录事件对象的update(),它返回一个对象target: null,并this.state.value更新从""undefined.这段代码与Forms文档上的示例差异很小,为什么我似乎无法获得事件目标?

javascript event-handling javascript-events reactjs

1
推荐指数
1
解决办法
6314
查看次数