小编cne*_*uro的帖子

Meteor.user()仅返回其_id

在用户(Meteor.loginWithPassword()Accounts.createUser两个客户端)记录用户或创建新用户之后,我可以在他们的回调中确认Meteor.user()确实包含所有设置记录的属性.

{ _id: "XXX",
  profile: {
     name: "Joe Shmoe",
     thumbnail: "http://www.YYY.com/ZZZ.jpg"
  },
  username: "joeshmoe" }
Run Code Online (Sandbox Code Playgroud)

此外,根据官方文件,

默认情况下,当前用户的用户名,电子邮件和个人资料将发布到客户端.

那么,当我尝试在我的模板中访问这些字段时,是否有人能够说出原因

Template.login.user_name = function () {
    return (Meteor.userId() ? Meteor.user().profile.name : '')
};
Run Code Online (Sandbox Code Playgroud)

它失败了,因为Meteor.user()只返回{_id: "XXX"}没有它的实际属性?即用户肯定已登录,但用户对象突然丢失/正在隐藏其所有属性.

谁知道问题可能是什么?

非常感谢.

编辑: 这发生在Meteor 0.5.4,这是撰写本文时的最新版本.接受的答案确实解决了这个问题; 有时Meteor.userId()在Object的其余部分从服务器到达之前已经有效.感谢大家.

meteor

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

Internet Explorer和tspan垂直对齐

要垂直对齐tspan元素的内部text在SVG,CSS属性元素alignment-baseline,并dominant-baseline在Chrome和FF,分别工作的伟大.到现在为止还挺好.

使用Internet Explorer它有点疯狂:

  • 一个开放的bug报告声称这些属性不适用于IE9-11 ......
  • ...但官方文件说明alignment-baseline支持
  • CSS功能嗅探在IE9和IE11报告说,他们支持alignment-baseline以及dominant-baselinetspan,但他们没有任何价值的工作
  • 为了给挫折添加困惑,这个MSDN开发页面简单地说两个属性当前都不受支持

对于IE9来说这不是一个问题(人们可能只是破解了所需的对齐),但由于我想摆脱浏览器检测,我想知道:

  • 有可行的跨浏览器解决方案吗?
  • 为什么甚至IE11不支持这个基本的SVG样式属性以及如何解决这个问题?

谢谢!

html javascript css svg

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

当所有模板项目在Meteor中完成渲染时回调?

我正在获取一组记录并将它们放在一个模板中,让它们渲染{{#each}},我想显示一个加载图标,直到最后一个DOM节点被渲染.

我的问题是我还没有找到一种方法来查询状态/触发最后一个项目的回调,也就是要更新/重新绘制的最后一个DOM节点.

在我的HTML文件中看起来有点像这样:

<template name="stuff">
    {{#each items}}
        <div class="coolView">{{cool_stuff}}</div>
    {{/each}}
</template>
Run Code Online (Sandbox Code Playgroud)

在客户端JS文件中:

// returns all records of Stuff belonging to the currently logged-in user
Template.stuff.items = function () {
    Session.set('loading_stuff', true);
    return Items.find({owner: Meteor.userId()}, {sort: {created_time: -1}});
};

Template.stuff.rendered = function() {
    // every time something new is rendered, there will have been loading of the DOM. 
    // wait a short while after the last render to clear any loading indication.
    Session.set('loading_stuff', true);
    Meteor.setTimeout(function() {Session.set('loading_stuff', false);}, 300);
}; …
Run Code Online (Sandbox Code Playgroud)

publish-subscribe meteor

6
推荐指数
2
解决办法
5713
查看次数

通过pip install在ubuntu上安装pysox,无法解析sox.h

我正在尝试使用pip(easy_install抛出完全相同的错误)在Ubuntu 12.04.2 LTS上安装pysox包.

$ pip install pysox
[...]
building 'pysox.sox' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pysox/sox.c -o build/temp.linux-x86_64-2.7/pysox/sox.o

pysox/sox.c:227:17: fatal error: sox.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我的系统安装了:

$ dpkg --list | grep sox
ii  libsox-fmt-all      14.3.2-3    All SoX format libraries
ii  libsox-fmt-alsa     14.3.2-3    SoX alsa format I/O library
ii  libsox-fmt-ao       14.3.2-3    SoX Libao format I/O library
ii  libsox-fmt-base     14.3.2-3    Minimal set of SoX format libraries
ii  libsox-fmt-ffmpeg   14.3.2-3    SoX ffmpeg format …
Run Code Online (Sandbox Code Playgroud)

python ubuntu pip sox

3
推荐指数
2
解决办法
4042
查看次数

标签 统计

meteor ×2

css ×1

html ×1

javascript ×1

pip ×1

publish-subscribe ×1

python ×1

sox ×1

svg ×1

ubuntu ×1