diff --git a/packages/uni-template-compiler/lib/app/service.js b/packages/uni-template-compiler/lib/app/service.js index df156cc340376c25b263f72842f81576ab16d591..ee9add4808153c05cde2172ebf3eeeabfa488322 100644 --- a/packages/uni-template-compiler/lib/app/service.js +++ b/packages/uni-template-compiler/lib/app/service.js @@ -50,7 +50,7 @@ function parseKey (el) { } const forEl = getForEl(el) if (!forEl) { - isVar(el.key) && (el.key = createGenVar(el.attrsMap[ID])('a-key', el.key)) + return isVar(el.key) && (el.key = createGenVar(el.attrsMap[ID])('a-key', el.key)) } if (!isVar(forEl.for)) { return diff --git a/packages/uni-template-compiler/lib/index.js b/packages/uni-template-compiler/lib/index.js index 2ff6ad5b78076919d880a0879a032e7850408b7a..cacdda93af24daa6d1eca5174f6aa282a8baa3c7 100644 --- a/packages/uni-template-compiler/lib/index.js +++ b/packages/uni-template-compiler/lib/index.js @@ -36,15 +36,22 @@ module.exports = { options.isReservedTag = (tagName) => !isComponent(tagName) // 非组件均为内置 options.getTagNamespace = () => false - // clear staticRenderFns - const compiled = compile(source, options) - - return compiled + try { + return compile(source, options) + } catch (e) { + console.error(`'错误:${options.resourcePath}'`) + throw new Error(e.message) + } } else if (options.view) { (options.modules || (options.modules = [])).push(require('./app/view')) options.optimize = false // 暂不启用 staticRenderFns options.isReservedTag = (tagName) => false // 均为组件 - return compile(source, options) + try { + return compile(source, options) + } catch (e) { + console.error(`'错误:${options.resourcePath}'`) + throw new Error(e.message) + } } if (!options.mp) { // h5