ExtJs6学习笔记 -- 主题更换

一、将所有主题相关的css包拷贝到自己的项目目录下,看如下截图:

        将  ext-6.0.1\build\classic\  目录下的所有主题:

                                        220241_twfZ_2300623.png

    拷贝到你项目的 WebCentent 目录下,(如下是我的目录结构):

                                                                        220424_Vu9q_2300623.png

     不需要管红叉叉!!

二、下面就是代码啦:

          我的js代码:

Ext.onReady(function() {
	Ext.create('Ext.window.Window', {
		title : '主题更换',
		width : 500,
		height : 300,
		autoShow : true,
		renderTo : Ext.getBody(),
		layout:'hbox',
		tbar : {
			layout:'auto',
			xtype : 'combo',
			labelWidth : '40',
			fieldLabel : 'Theme',
			displayField : 'name',
			valueField : 'value',
			queryMode : 'local',
			width:200,
			emptyText:'个性主题',
			store : Ext.create('Ext.data.Store', {
				fields : [ 'value', 'name' ],
				data : [ {
					value : 'neptune',
					name : 'Neptune主题'
				}, {
					value : 'crisp',
					name : 'Crisp主题'
				}, {
					value : 'classic',
					name : 'Classic主题'
				}, {
					value : 'gray',
					name : 'Gray主题'
				} ,{
					value : 'triton',
					name : 'Triton主题'
				}]
			}),
			listeners : {
				select : function(combo) {
					var theme = combo.getValue();
					var href = 'extJs/build/classic/theme-' + theme
							+ '/resources/theme-' + theme
							+ '-all-debug.css';
					var link = Ext.fly('theme');

					if (!link) {
						link = Ext.getHead().appendChild({
							tag : 'link',
							id : 'theme',
							rel : 'stylesheet',
							href : ''
						});
					}
					;
					link.set({
						href : Ext.String.format(href, theme)
					});
				}
			}
		}
	});
});

效果图如下:

221228_JoZi_2300623.png

点击切换就可以了。

转载于:https://my.oschina.net/mercyyang/blog/628862

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值