【问题标题】:Setting Page Title with useraccounts:flow-router使用用户帐户设置页面标题:flow-router
【发布时间】:2016-03-22 00:33:51
【问题描述】:

我才刚刚开始真正深入 Meteor 并开始一些个人项目,但我偶然发现了一些我还没有找到答案的东西。我正在尝试设置用于登录、注册等的页面标题。有解决方案吗?我在文档中没有看到可以在这些配置语句中添加选项的任何地方。

这是我的routes.jsx 文件:

AccountsTemplates.configureRoute("changePwd");
AccountsTemplates.configureRoute("forgotPwd");
AccountsTemplates.configureRoute("resetPwd");
AccountsTemplates.configureRoute("signIn");
AccountsTemplates.configureRoute("signUp");
AccountsTemplates.configureRoute("verifyEmail");

谢谢!

【问题讨论】:

    标签: javascript meteor meteor-accounts flow-router


    【解决方案1】:

    你应该能够做到这一点:

    FlowRouter.triggers.enter([function(){
      document.title = FlowRouter.current().path;
    ]);
    

    这会将页面标题设置为所有路由的路由路径。如果您想要特定于路线的标题,那么您可以在每条路线上单独添加触发器。 (docs)

    【讨论】:

    • 这行得通,我已经尝试对其进行调整,以便 document.title = FlowRouter.current().name; 但它不断返回 undefined。我还将AccountsTemplates.configureRoute("signIn"); 更新为AccountsTemplates.configureRoute("signIn", { name: 'Sign In' });
    • 我现在开始工作了。 name 是 route 的孩子,所以我使用的代码是 FlowRouter.triggers.enter([function() { document.title = FlowRouter.current().route.name; }]);
    猜你喜欢
    • 2014-07-11
    • 2018-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-28
    • 1970-01-01
    相关资源
    最近更新 更多