簡體   English   中英

流星-如何正確路由模板事件功能內部

[英]Meteor - How to correctly route inside Template event function

我有一個基本模板:

<template name="ApplicationLayout">
    {{> yield}}
</template>

然后使用Iron Router將模板路由到其中,如下所示:

Router.configure({
  layoutTemplate: 'ApplicationLayout',
  notFoundTemplate: 'home'
});
Router.route('/', function () {
  this.render('home');
});

每當有人到達站點時,總是會向他們顯示agegate模板。 他們單擊提交按鈕后,我想切換到其他頁面(主頁)。

Template.agegate.events({
    "click #submit": function (event) {
        this.render('home');
    }
});

路由實際上有效(我到達了所需的頁面),但是它引發了一個錯誤:

Uncaught TypeError: undefined is not a function

我假設這是因為thisthis.render('home')指的是當前模板,而它需要引用父模板(在ApplicationLayout模板)。 但是我不知道該怎么做,或者那是否有意義。

那么,如何正確路由Template事件函數內部?

嘗試使用Router.go('/') ,這足夠了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM