From eb3d3c02c30577b08a3a897be7650a7ff60db13f Mon Sep 17 00:00:00 2001 From: xst Date: Wed, 16 Jan 2019 10:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=E3=80=91=E4=BF=AE=E5=A4=8Dcompile?= =?UTF-8?q?=E9=98=B6=E6=AE=B5genCode=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...347\274\226\350\257\221\347\232\204\343\200\213.js" | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git "a/\343\200\212template \346\250\241\346\235\277\346\230\257\346\200\216\346\240\267\351\200\232\350\277\207 Compile \347\274\226\350\257\221\347\232\204\343\200\213.js" "b/\343\200\212template \346\250\241\346\235\277\346\230\257\346\200\216\346\240\267\351\200\232\350\277\207 Compile \347\274\226\350\257\221\347\232\204\343\200\213.js" index 589038d..ba8c9e0 100644 --- "a/\343\200\212template \346\250\241\346\235\277\346\230\257\346\200\216\346\240\267\351\200\232\350\277\207 Compile \347\274\226\350\257\221\347\232\204\343\200\213.js" +++ "b/\343\200\212template \346\250\241\346\235\277\346\230\257\346\200\216\346\240\267\351\200\232\350\277\207 Compile \347\274\226\350\257\221\347\232\204\343\200\213.js" @@ -22,6 +22,8 @@ const defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g const forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/ +const stripBracket = /^\(|\)$/g; + const stack = []; let currentParent, root; @@ -128,7 +130,7 @@ function processFor (el) { if ((exp = getAndRemoveAttr(el, 'v-for'))) { const inMatch = exp.match(forAliasRE); el.for = inMatch[2].trim(); - el.alias = inMatch[1].trim(); + el.alias = inMatch[1].trim().replace(stripBracket, '').trim(); } } @@ -292,7 +294,7 @@ function generate (rootAst) { const children = el.children; if (children && children.length > 0) { - return `${children.map(genNode).join(',')}`; + return `[${children.map(genNode).join(',')}]`; } } @@ -304,9 +306,9 @@ function generate (rootAst) { } else { const children = genChildren(el); let code; - code = `_c('${el.tag},'{ + code = `_c('${el.tag}',{ staticClass: ${el.attrsMap && el.attrsMap[':class']}, - class: ${el.attrsMap && el.attrsMap['class']}, + 'class': ${el.attrsMap && el.attrsMap['class']}, }${ children ? `,${children}` : '' })`