【问题标题】:Check user email status before page loads在页面加载之前检查用户电子邮件状态
【发布时间】:2016-04-15 08:27:46
【问题描述】:

我正在使用除非空格键功能来检查用户是否验证了他们的电子邮件地址。在生产中,我假设由于延迟,屏幕会显示此通知,然后如果电子邮件已通过验证,则会在一秒钟后更改。有没有办法减慢页面加载速度,以便在页面加载之前检查用户的电子邮件状态?

<template name="mainLayout">

        {{#unless currentUser.emails.[0].verified}}
            <p class="alert alert-warning text-center">We have sent you an email to verify your email address. All users must confirm their email address to access the BHR platform.</p>

        {{else}}

        <div id="content" class="content">
            <div class="container">
                {{>Template.dynamic template=main}}     
            </div>      
        </div>

        {{/unless}}

    </div>

</template>

【问题讨论】:

    标签: meteor spacebars


    【解决方案1】:

    延迟是因为第一次渲染模板时Meteor.user() 对象尚未完全加载。然后它会加载并反应性地交换这些部分。

    您需要在加载用户对象时显示加载屏幕/微调器。具体操作方式取决于您使用的路由器。

    【讨论】:

      【解决方案2】:

      我相信这就是迈克尔的建议。将模板包装在:

      {{#if Template.subscriptionsReady}}
      
      {{/if}}
      

      【讨论】:

        猜你喜欢
        • 2022-12-10
        • 1970-01-01
        • 2010-09-14
        • 2016-11-11
        • 1970-01-01
        • 2019-07-23
        • 2019-11-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多