【发布时间】:2018-06-19 00:01:56
【问题描述】:
我最近才开始使用 Meteor 和 Iron Router,所以我遇到了一些问题。
我希望有一个非常基本的网站,并且快到了,但是在为各种目录重用其中一个模板时,页面不会刷新,这会导致它显示上一页,尽管 URL 显示正确页。
一旦我在浏览器上点击刷新,页面实际上会重新加载正确的页面,但我宁愿不必总是刷新页面,只想简单地点击一个链接并获取正确的信息。
我尝试了一些我见过的与类似问题有关的解决方案,但它们似乎都比我的更独特。我已经包含了来自 meteor 的 .js 文件。
Router.route('/', function () {
this.render('iotprofiler');
});
Router.route('index.html', function () {
this.render('iotprofiler');
});
Router.route('/device(.*)', function () {
//document.location.reload(true);
this.render('profile');
});
if(Meteor.isClient){
//this code only runs on the client
var directory = Iron.Location.get().path;
var start = directory.lastIndexOf("/");
var stop = directory.search(".html");
var parseddir = directory.slice(start + 1,stop);
console.log(parseddir);
Template.iotprofiler.helpers({
'device': function(){
return DeviceList.find();
}
});
Template.profile.helpers({
'iotdevice': function(){
return DeviceList.find({model: parseddir});
}
});
}
【问题讨论】:
标签: javascript meteor refresh router iron-router