From 5c85d2d0b33e4249cbfc7842c7784d32ef392e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=AD=A6=E6=96=87?= Date: Sat, 7 Mar 2020 21:43:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96js=20=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/vcCore/vcFramework.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/public/vcCore/vcFramework.js b/public/vcCore/vcFramework.js index 70d5c4a53..5fb004d32 100644 --- a/public/vcCore/vcFramework.js +++ b/public/vcCore/vcFramework.js @@ -242,7 +242,13 @@ for (let i = 0; i < _componentScript.length; i++) { //一段一段执行script - eval(_componentScript[i]); + try{ + eval(_componentScript[i]); + }catch(e){ + console.log('js脚本错误',_componentScript[i]); + console.error(e); + } + } //初始化vue 对象 @@ -374,9 +380,9 @@ let componentName = _componentVcCreate.getAttribute("name"); throw "组件" + componentName + "对应js 未包含 {} "; } - let newJs = _js.substring(0,position); + let newJs = _js.substring(0,position+1); newJs = newJs + propsJs; - newJs = _js.substring(position + 1, _js.length); + newJs = newJs +_js.substring(position + 1, _js.length); return newJs; }; @@ -401,7 +407,7 @@ } let namespace = ""; if (!_componentVcCreate.hasAttribute("namespace")) { - namespace = DEFAULT_NAMESPACE; + namespace = 'default'; } else { namespace = tag.getAttributeValue("namespace"); } @@ -415,9 +421,9 @@ let position = _js.indexOf("{"); let propsJs = "\nvar $namespace='" + namespace.trim() + "';\n"; - let newJs = _js.substring(0,position); + let newJs = _js.substring(0,position+1); newJs = newJs + propsJs; - newJs = _js.substring(position + 1, _js.length); + newJs = newJs+ _js.substring(position + 1, _js.length); return newJs; };