From 7e0cd629ab5d531737ae9e4d84e45e1f4eee59f5 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Wed, 4 Sep 2019 19:50:40 +0800 Subject: [PATCH] feat(cli): wraps text in a tag (nvue) --- .../build/vue-loader.conf.js | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/packages/vue-cli-plugin-hbuilderx/build/vue-loader.conf.js b/packages/vue-cli-plugin-hbuilderx/build/vue-loader.conf.js index 8f623da8..0d77cadc 100644 --- a/packages/vue-cli-plugin-hbuilderx/build/vue-loader.conf.js +++ b/packages/vue-cli-plugin-hbuilderx/build/vue-loader.conf.js @@ -17,9 +17,33 @@ const deprecated = { } } -if (process.env.UNI_USING_NVUE_COMPILER) { +if (process.env.UNI_USING_NVUE_COMPILER) { + const wrapperTextTag = function (el, options) { + const tag = el.tag + if (tag === 'text' || tag === 'button') { + return + } + const children = el.children + children.forEach((child, index) => { + if (child.text) { + children.splice(index, 1, { + type: 1, + tag: 'u-text', + attrsList: [], + attrsMap: {}, + rawAttrsMap: {}, + parent: el, + children: [child], + plain: true + }) + } + }) + } + modules.push({ - postTransformNode (el) { + postTransformNode (el, options) { + wrapperTextTag(el, options) + if (TAGS.includes(el.tag)) { el.tag = 'u-' + el.tag } -- GitLab