From 624965ee9762987eb6ba0af0a1bf04ced020b1ea Mon Sep 17 00:00:00 2001 From: wobless <444818988@qq.com> Date: Wed, 29 Aug 2018 17:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=8D=E5=8E=86=E5=85=83=E7=B4=A0=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/laydate.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/laydate.js b/src/laydate.js index 0a75401..e5d2058 100644 --- a/src/laydate.js +++ b/src/laydate.js @@ -11,24 +11,8 @@ "use strict"; var isLayui = window.layui && layui.define, ready = { - getPath: function(){ - var jsPath = document.currentScript ? document.currentScript.src : function(){ - var js = document.scripts - ,last = js.length - 1 - ,src; - for(var i = last; i > 0; i--){ - if(js[i].readyState === 'interactive'){ - src = js[i].src; - break; - } - } - return src || js[last].src; - }(); - return jsPath.substring(0, jsPath.lastIndexOf('/') + 1); - }() - //获取节点的style属性值 - ,getStyle: function(node, name){ + getStyle: function(node, name){ var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null); return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name); } @@ -68,7 +52,22 @@ v: '5.0.9' ,config: {} //全局配置项 ,index: (window.laydate && window.laydate.v) ? 100000 : 0 - ,path: ready.getPath + ,path: '' + ,getPath: function(){ + var jsPath = document.currentScript ? document.currentScript.src : function(){ + var js = document.scripts + ,last = js.length - 1 + ,src; + for(var i = last; i > 0; i--){ + if(js[i].readyState === 'interactive'){ + src = js[i].src; + break; + } + } + return src || js[last].src; + }(); + return jsPath.substring(0, jsPath.lastIndexOf('/') + 1); + } //设置全局项 ,set: function(options){ @@ -106,6 +105,7 @@ //组件构造器 ,Class = function(options){ var that = this; + laydate.path = laydate.path || laydate.getPath(); that.index = ++laydate.index; that.config = lay.extend({}, that.config, laydate.config, options); laydate.ready(function(){ @@ -1863,4 +1863,4 @@ }() ); -}(); \ No newline at end of file +}();