---
title: "easyui layout使用问题"
author: "elfasd"
date: "2013-07-19T14:06:15Z"
tags: []
categories: ["Web前端"]
slug: "easyui-layout"
draft: false
lastmod: "2013-07-19T14:06:55Z"
id: 1910145
url: "https://elfasd.iteye.com/blog/1910145"
---

easyui layout使用问题

在做一个easyui layout的demo的时候，遇到一个问题，就是不断该表窗口大小的时候有时候会报错：无效的参数

定位了一下，发现是jquery-1.8.0.js中有这么一行报错：

 

        f\[b] = d;

f\[b]接收的应该是 数字  +  px，但是d是NaN   +  px，这样就报错了

 

 

这个d是从最开始的jquery文件function (A, w)中的w赋值过来的，打个debugger端点发现这个w就是个undefined，搞不懂了，是浏览器问题？

暂时加了一个判断应付了事，但是有人遇到过这样的问题么？解决方案呢？：

if(d==='NaNpx'){  
        
     //do nothing    
       }else {  
        f\[b] = d;  
       }

 下面是这个demo的界面：

&lt;%@ page language="java" contentType="text/html; charset=GBK"  
    pageEncoding="GBK"%&gt;  
&lt;%@ taglib prefix="c" uri="[http://java.sun.com/jsp/jstl/core"%](http://java.sun.com/jsp/jstl/core%22%)&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[http://www.w3.org/TR/html4/loose.dtd](http://www.w3.org/TR/html4/loose.dtd)"&gt;  
&lt;html&gt;  
&lt;head&gt;  
 &lt;c:set value="${pageContext.request.contextPath}" var="path" scope="page"/&gt;  
 &lt;link rel="stylesheet" type="text/css" href="${path}/js/com/nari/component/easyui/themes/default/easyui.css"&gt;   
 &lt;link rel="stylesheet" type="text/css" href="${path}/js/com/nari/component/easyui/themes/icon.css"&gt;   
 &lt;link rel="stylesheet" type="text/css" href="${path}/js/com/nari/component/easyui/demo.css"&gt;   
 &lt;script type="text/javascript" src="${path}/js/com/nari/component/easyui/jquery.min.js"&gt;&lt;/script&gt;   
 &lt;script type="text/javascript" src="${path}/js/com/nari/component/easyui/jquery.easyui.min.js"&gt;&lt;/script&gt;   
 &lt;script type="text/javascript" src="${path}/js/com/nari/component/easyui/locale/easyui-lang-zh\_CN.js"&gt;&lt;/script&gt;   
 &lt;meta http-equiv="Content-Type" content="text/html; charset=GBK"&gt;  
 &lt;title&gt;tbUser初始化查询页面&lt;/title&gt;  
     &lt;style type="text/css"&gt;  
  body {  
   margin:0px;  
   padding:0px;  
   width:100%;  
   height:100%;  
  }  
 &lt;/style&gt;  
 &lt;script&gt;  
  var settime = null;  
  function redraw(){  
   $('#wrap').layout('resize');   
   $('#subWrap').layout('panel', 'north').panel('resize',{width:$('#subWrap').width()});  
   $('#subWrap').layout('panel', 'center').panel('resize',{width:$('#subWrap').width()});  
   $('#subWrap').layout('resize');  
  }  
  $(function(){    
   $(window).resize(function(){  
    if(settime != null)  
     clearTimeout(settime);  
    settime=setTimeout("redraw()",100);  
   });       
   var p1 = $('body').layout('panel','west').panel({  
    onCollapse:function(){  
     if(settime != null)  
      clearTimeout(settime);  
     settime=setTimeout("redraw()",100);  
    },  
    onExpand:function(){  
     if(settime != null)  
      clearTimeout(settime);  
     settime=setTimeout("redraw()",100);  
    },  
    onResize:function(width,height){  
     if(settime != null)  
      clearTimeout(settime);  
     settime=setTimeout("redraw()",100);  
    }  
   });      
   var p2 = $('body').layout('panel','east').panel({  
    onCollapse:function(){  
     if(settime != null)  
      clearTimeout(settime);  
     settime=setTimeout("redraw()",100);  
    },  
    onExpand:function(){  
     if(settime != null)  
      clearTimeout(settime);  
     settime=setTimeout("redraw()",100);  
    },  
    onResize:function(width,height){  
     if(settime != null)  
      clearTimeout(settime);  
     settime=setTimeout("redraw()",100);  
    }  
   });   
  });  
 &lt;/script&gt;  
&lt;/head&gt;  
&lt;body&gt;  
 &lt;body class="easyui-layout"&gt;  
 &lt;div region="north" border="false" style="height:30px;background:#B3DFDA;"&gt;north region&lt;/div&gt;  
 &lt;div region="west" split="true" title="tree" style="width:150px;padding:10px;"&gt;west content&lt;/div&gt;  
 &lt;div region="east" split="true" title="East" style="width:100px;padding:10px;"&gt;east region&lt;/div&gt;  
 &lt;div region="south" border="false" style="height:20px;background:#A9FACD;"&gt;south region&lt;/div&gt;  
 &lt;div region="center" border="true" title="center" style="border-left:0px;border-right:0px;"&gt;    
  &lt;div class="easyui-layout" id="subWrap" style="width:100%;height:100%;background:#0A3DA4;"&gt;  
   &lt;div region="north" border="true" title="condtion" split="true" style="height:200px;background:#A9FACD;"&gt;  
    &lt;p style="font-size:48;margin:0px auto;text-align:center;"&gt;sub north region&lt;/p&gt;  
   &lt;/div&gt;  
   &lt;div region="center" border="true" title="result" split="true" style="background:#E2E377;"&gt;  
    &lt;p style="font-size:48;margin:0px auto;text-align:center;"&gt;sub center region&lt;/p&gt;  
   &lt;/div&gt;     
  &lt;/div&gt;    
 &lt;/div&gt;  
   
&lt;/body&gt;  
&lt;/html&gt;