簡體   English   中英

流星鐵路由器強制頁面刷新

[英]Meteor Iron-Router force page refresh

我剛剛開始使用MeteorIron 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});
        }

    });
}

您的問題是parseddir沒有反應

一種解決方案是將文檔渲染模板與鐵路由器的數據一起使用。 只需在呈現profile模板時將parseddir作為數據提供給profile模板,然后在助手中使用this.parseddir即可獲取實際數據。

暫無
暫無

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

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