每次页面呈现时,我都会收到以下错误.我以前没有收到这些,他们刚开始有一天,我发现的唯一解决方案是卸载快速渲染.以任何方式改变路线似乎没有任何影响.知道问题的根源是什么吗?
我发现以下页面描述了类似的错误,但我在waitOn函数中没有this.redirect(...)或Router.go(...):https: //github.com/kadirahq/fast -render#3- waiton和-订阅的方法
以下是帐户路由和相应控制器的代码:
Router.route("/account", {
name: "Account",
controller: simpleWebsiteController,
waitOn: function () {
return [
Meteor.subscribe("userData"),
Meteor.subscribe("userMessages")
]
},
data: function () {
var messages = Collections.Messages.find({userId: Meteor.userId()},{sort: { creationDate: -1 }});
var posts = Collections.Posts.find({});
var comments = Collections.Comments.find({});
return {
content: "page-account",
userMessages: messages,
userComments: comments,
userPosts: posts
};
},
onBeforeAction: function () {
// If the user is not logged in, redirect to login page
var path = this.location.get().path;
if (!Meteor.userId() && path.indexOf("/login") != 0)
this.location.go("/login");
else
this.next();
}
});
Run Code Online (Sandbox Code Playgroud)
控制器:
var simpleWebsiteController = RouteController.extend({
layoutTemplate: "MainLayout",
waitOn: function () {
return [
Meteor.subscribe("userData"),
Meteor.subscribe("categoriesList"),
Meteor.subscribe("cityData")
]
},
onBeforeAction: function () {
// If the user is not logged in, redirect to login page
var path = this.location.get().path;
if (!Meteor.userId() && path.indexOf("/login") != 0)
this.location.go("/login");
else
this.next();
},
onAfterAction: function() {
$('.row-offcanvas').removeClass('active');
$('.collapse').removeClass('active');
},
fastRender: true
});
Run Code Online (Sandbox Code Playgroud)
有关此错误原因的详细信息,请查看此答案.
不幸的是,流程路由器作为依赖项的快速渲染包正在搞乱流星内部,并且当流星的核心代码得到更新时会破坏你的代码.
您可以克隆和编辑kadira的快速渲染并修复此问题.
转到项目目录下的packages文件夹
cd your_project_dir/packages/
git clone https://github.com/kadirahq/fast-render.git
Run Code Online (Sandbox Code Playgroud)
然后,在第23行编辑your_project_dir/packages/fast-render/lib/server/context.js:
// support for Meteor.user
// Fibers.current._meteor_dynamics = {};
Fibers.current._meteor_dynamics = []; // <-- Fixed
Run Code Online (Sandbox Code Playgroud)
现在这将覆盖kadira的v2.16.0快速渲染包.
| 归档时间: |
|
| 查看次数: |
796 次 |
| 最近记录: |