From e67c163757bfca95c297b4f03cd989f3519049ee Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 5 May 2022 12:33:44 +0800 Subject: [PATCH] feat(App): skip functional components (view) --- .../uni-template-compiler/lib/app/parser/tag-parser.js | 9 +++++++++ packages/uni-template-compiler/lib/util.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/uni-template-compiler/lib/app/parser/tag-parser.js b/packages/uni-template-compiler/lib/app/parser/tag-parser.js index 0ac94d980..70e7d0dc0 100644 --- a/packages/uni-template-compiler/lib/app/parser/tag-parser.js +++ b/packages/uni-template-compiler/lib/app/parser/tag-parser.js @@ -4,8 +4,17 @@ const { const tags = require('@dcloudio/uni-cli-shared/lib/tags') +// web components +const elements = ['uni-view'] + // 仅限 view 层 module.exports = function parseTag (el) { + const tag = el.tag + const element = elements.find(element => tag === element || 'uni-' + tag === element) + if (element) { + el.tag = element + return + } if (el.tag.indexOf('v-uni-') !== 0 && hasOwn(tags, el.tag)) { el.tag = 'v-uni-' + el.tag } diff --git a/packages/uni-template-compiler/lib/util.js b/packages/uni-template-compiler/lib/util.js index fa0ef6afa..5e68bb7dc 100644 --- a/packages/uni-template-compiler/lib/util.js +++ b/packages/uni-template-compiler/lib/util.js @@ -210,7 +210,7 @@ function isComponent (tagName) { return false } } - return !hasOwn(tags, getTagName(tagName.replace('v-uni-', ''))) + return !hasOwn(tags, getTagName(tagName.replace(/^(v-)?uni-/, ''))) } function makeMap (str, expectsLowerCase) { -- GitLab