EasyUI切换主题风格

实现EasyUI切换主题。

参考文档如下:

https://www.jeasyui.net/extension/209.html

https://www.runoob.com/jeasyui/ext-themes.html 

以上各主题下载地址:jquery easyui themes

代码如下

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>切换主题</title>
<!--这里-->
		<link id="easyuiTheme"  rel="stylesheet" type="text/css" href="./jquery-easyui/themes/default/easyui.css">
<!--这里-->
		<link rel="stylesheet" type="text/css" href="./jquery-easyui/themes/icon.css">

		<script type="text/javascript" src="./jquery-easyui/jquery.min.js"></script>
		<script type="text/javascript" src="./jquery-easyui/jquery.easyui.min.js"></script>
		
		
	</head>
	<body>
		<div id = "maindiv">
				<div id="tablediv" style="width:7100px;height:260px;">
					<table id="tabledg" class="easyui-datagrid" title="Format DataGrid Columns" style="width:700px;height:250px; "
				>
						<thead>
							<tr>
								<th data-options="field:'name',width:80">Item ID</th>
								<th data-options="field:'listprice',width:80,align:'right'">List Price</th>
							</tr>
						</thead>
					</table>
				</div>
		<div style="position: absolute;right: 14px;top:42px;">
		          <div style="padding:5px;">
		            <a href="javascript:void(0);" rel="external nofollow" class="easyui-menubutton" data-options="menu:'#layout_north_pfMenu',iconCls:'icon-ok'">更换皮肤</a>
		          </div>
		        </div>
		        <div id="layout_north_pfMenu" class="easyui-menu" style=" display: none;">
		          <div md="ssss" >black</div>
		          <div >default</div>
		          <div>bootstrap</div>
		          <div >gray</div>
		          <div >metro</div>
		        </div>
		</div>
	
		<script>
			function getData() {
				var rows = [];
				for (var i = 1; i <= 10; i++) {
					var amount = Math.floor(Math.random() * 1000);
					var price = Math.floor(Math.random() * 1000);
					rows.push({
						inv: 'Inv No ' + i,
						date: $.fn.datebox.defaults.formatter(new Date()),
						name: 'Name ' + i,
						status: (i % 2)?"投":"退",
						listprice: amount
					});
				}

				let d = {};
				d["rows"] = rows;
				d["total"] = rows.length;
				return d;
			}

			$(function() {
				let data = getData();
				$("#tabledg").datagrid("loadData", data);
			})

			/**
			   * 更换EasyUI主题的方法
			   * @param themeName
			   * 主题名称
			   */
			function changeTheme(themeName) {
			    var $easyuiTheme = $('#easyuiTheme');
			    var url = $easyuiTheme.attr('href');
			    var href = url.substring(0, url.indexOf('themes')) + 'themes/' + themeName + '/easyui.css';
			    $easyuiTheme.attr('href', href);
			   
			  };
			  
			  $('#layout_north_pfMenu').menu({
			      onClick:function(item){
					  console.log($(item.target).prop("md"))
					  console.log($(item.target).attr("md"))
			  		changeTheme(item.text);
			      }
			  });			
		</script>
	</body>
</html>

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值