From 92d682a11a27d8fda573555512fff69a94a94e40 Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 15 Jul 2021 11:11:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:(mp-alipay):=20=E6=94=AF=E4=BB=98=E5=AE=9D?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=B9=B3=E5=8F=B0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=8B=AC=E6=9C=89=E5=86=85=E7=BD=AE=E7=BB=84=E4=BB=B6=E5=88=A4?= =?UTF-8?q?=E6=96=AD=20#2410#issuecomment-878974559?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/compiler-mp-alipay.spec.js | 5 + packages/uni-template-compiler/lib/mp.js | 104 ++++++++++-------- 2 files changed, 61 insertions(+), 48 deletions(-) diff --git a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js index 2c918ac05..6d016649a 100644 --- a/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js @@ -229,5 +229,10 @@ describe('mp:compiler-mp-alipay', () => { '', '' ) + + assertCodegen( + '', + '' + ) }) }) diff --git a/packages/uni-template-compiler/lib/mp.js b/packages/uni-template-compiler/lib/mp.js index a15c2fbc8..67d0d9d6e 100644 --- a/packages/uni-template-compiler/lib/mp.js +++ b/packages/uni-template-compiler/lib/mp.js @@ -1,54 +1,62 @@ const EVENTS = { click: 'tap' } -const tags = [ - 'slot', - 'block', - 'component', - 'template', +const tags = { + // 小程序平台通用组件 + base: [ + 'slot', + 'block', + 'component', + 'template', - 'ad', - 'audio', - 'button', - 'camera', - 'canvas', - 'checkbox', - 'checkbox-group', - 'cover-image', - 'cover-view', - 'form', - 'functional-page-navigator', - 'icon', - 'image', - 'input', - 'label', - 'live-player', - 'live-pusher', - 'map', - 'movable-area', - 'movable-view', - 'navigator', - 'official-account', - 'open-data', - 'picker', - 'picker-view', - 'picker-view-column', - 'progress', - 'radio', - 'radio-group', - 'rich-text', - 'scroll-view', - 'slider', - 'swiper', - 'swiper-item', - 'switch', - 'text', - 'textarea', - 'video', - 'view', - 'web-view', - 'editor' -] + 'ad', + 'audio', + 'button', + 'camera', + 'canvas', + 'checkbox', + 'checkbox-group', + 'cover-image', + 'cover-view', + 'form', + 'functional-page-navigator', + 'icon', + 'image', + 'input', + 'label', + 'live-player', + 'live-pusher', + 'map', + 'movable-area', + 'movable-view', + 'navigator', + 'official-account', + 'open-data', + 'picker', + 'picker-view', + 'picker-view-column', + 'progress', + 'radio', + 'radio-group', + 'rich-text', + 'scroll-view', + 'slider', + 'swiper', + 'swiper-item', + 'switch', + 'text', + 'textarea', + 'video', + 'view', + 'web-view', + 'editor', + ], + // 支付宝小程序平台独有组件 + 'mp-alipay': [ + 'lifestyle', + 'life-follow' + ] +} const baseCompiler = { ref: 'data-ref', @@ -60,7 +68,7 @@ const baseCompiler = { * 目前 template 在前,script 在后,要做的话,就需要把 wxml 的生成机制放到 plugin 中才可以拿到真实的组件列表 */ isComponent (tagName) { - return !tags.includes(tagName) + return !tags.base.concat(tags[this.name] || []).includes(tagName) }, createFilterTag (filterTag, { content, -- GitLab