[英]Meteor Iron-Router force page refresh
我剛剛開始使用Meteor和Iron Router ,所以遇到了一些問題。
我正在尋找一個非常基本的網站,並且幾乎在那兒,但是在重用各個目錄的模板之一時,該頁面不會刷新,盡管URL顯示正確的頁面,但該頁面仍顯示上一頁。
一旦在瀏覽器中單擊“刷新”,該頁面實際上就會重新加載正確的頁面,但是我寧願不必始終刷新頁面, 而只需要單擊鏈接並獲取正確的信息即可 。
我嘗試了一些與類似問題相關的解決方案,但它們似乎都比我的獨特。 我已包含流星的 .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});
}
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.