我必须根据某些事件更改主题。我从sencha文档和厨房水槽了解到的是,我们必须在app.json的“ builds”块下输入所有主题
"builds": {
"classic": {
"toolkit": "classic",
"theme": "theme-classic"
},
"triton": {
"toolkit": "classic",
"theme": "theme-triton"
}
},
构建后,我们可以如下所示重新加载应用程序以获取特定主题。
location.search = "/?profile=classic";
location.search = "/?profile=triton";
但是它没有按预期工作。请提示。
答案 0 :(得分:1)
您只是在那儿的一半。 Sencha Cmd将为您的主题生成不同的清单。现在,您现在必须在应用程序加载时选择相应的清单。看看Microloader文档中的Dynamic Manifest部分。
有时您可能需要选择构建配置文件 客户端。为了简化此过程,Microloader定义了一个hook方法 称为“ Ext.beforeLoad”。如果您按照以下方式定义此方法, 您可以先控制“ Ext.manifest”的名称或内容 Microloader在利用其平台检测的同时对其进行处理。
对于您来说,它看起来像这样:
<script type="text/javascript">
var Ext = Ext || {};
Ext.beforeLoad = function (tags) {
var theme = location.href.match(/profile=([\w-]+)/);
theme = (theme && theme[1]) || 'classic';
Ext.manifest = theme;
};
</script>