From b6449e762c0a74ac84add88dc46f5139b2e6388d Mon Sep 17 00:00:00 2001 From: qiang Date: Tue, 7 Jul 2020 18:31:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20scope-slot=20?= =?UTF-8?q?=E4=B8=AD=E5=AE=9A=E4=B9=89=E7=9A=84=20class=20=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20question/100724=20(+1=20squashed=20commit)=20Squashed=20comm?= =?UTF-8?q?its:=20[2a9e362bd]=20fix:=20=E8=A7=A3=E5=86=B3=20scope-slot=20?= =?UTF-8?q?=E4=B8=AD=E5=AE=9A=E4=B9=89=E7=9A=84=20class=20=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20question/100724?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-mp-weixin/lib/uni.compiler.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/uni-mp-weixin/lib/uni.compiler.js b/packages/uni-mp-weixin/lib/uni.compiler.js index f6d43229ca..cab7979006 100644 --- a/packages/uni-mp-weixin/lib/uni.compiler.js +++ b/packages/uni-mp-weixin/lib/uni.compiler.js @@ -12,6 +12,12 @@ wx.createComponent({ ` } +function generateCssCode (ownerName) { + return ` +@import './${ownerName}.wxss' +` +} + function hasOwn (obj, key) { return Object.prototype.hasOwnProperty.call(obj, key) } @@ -61,7 +67,7 @@ module.exports = { } parentNode.attr.generic[slotName] = true - // 生成 scopedSlots 文件,包括 json,js,wxml,还需要更新 owner 的 usingComponents + // 生成 scopedSlots 文件,包括 json,js,wxml,wxss,还需要更新 owner 的 usingComponents if (!state.files) { state.files = {} } @@ -100,6 +106,11 @@ module.exports = { const jsContent = generateJsCode(genCode(t.objectExpression(objectProperties), true)) state.files[jsFile] = jsContent + const cssFile = resourcePath.replace(ownerName + extname, componentName + '.wxss') + const cssContent = generateCssCode(ownerName) + + state.files[cssFile] = cssContent + if (!state.generic) { state.generic = [] } @@ -108,4 +119,4 @@ module.exports = { return '' } -} +} -- GitLab