Javascript marionette.js首次在mainRegion中显示不同的视图后无法正确渲染

Javascript marionette.js首次在mainRegion中显示不同的视图后无法正确渲染,javascript,jquery-mobile,backbone.js,marionette,Javascript,Jquery Mobile,Backbone.js,Marionette,在我的代码中,当我再次从另一个页面返回主页面时,它无法正确呈现主区域中缺少的样式。就像go_to_main_page:函数触发时,它显示主页面,但我无法获得模板中指定的原始样式 var Page = new Marionette.Application(); Page.addRegions({ mainRegion: "#main-region" }); Page.MainView = Marionette.ItemView.extend({ id: "main-view",

在我的代码中,当我再次从另一个页面返回主页面时,它无法正确呈现主区域中缺少的样式。就像go_to_main_page:函数触发时,它显示主页面,但我无法获得模板中指定的原始样式

var Page = new Marionette.Application();
Page.addRegions({
    mainRegion: "#main-region"
});

Page.MainView = Marionette.ItemView.extend({
    id: "main-view",
    tagName: "div",

    template: "#main-template",
    events:{
        "click #another_page": "go_to_another_page",

    },
    go_to_another_page: function(){

        var anotherpageView = new Page.AnotherPageView();
        Page.mainRegion.show(anotherpageView);
    },
});

Page.AnotherPageView = Marionette.ItemView.extend({
    id: "id_another_page_id",
    tagName: "div",


    template: "#anotherpage-template",
    events:{
        "click #main_page": "go_to_main_page"
    },
    go_to_main_page: function() {

        var mainView = new Page.MainView();
        Page.mainRegion.show(mainView);


    }
});

Page.on("initialize:after", function(){
   var mainView = new Page.MainView();
   Page.mainRegion.show(mainView);

});
Page.start();

show应该只是复制模板。它根本不会触及你的样式表。你是如何引用你的CSS的?您的模板中指定了什么样式?我正在使用jquery mobile。代码可以在这里找到:,当您从另一个页面返回主页时,样式会发生变化。您的设置看起来不错。请解释你所说的风格是什么意思。由于样式表样式没有格式化元素,您的页面格式是否有问题?是的,我的样式表样式没有格式化元素。我的样式表样式也会更改和元素。