Skip to content

Commit

Permalink
fix(alita-core): 修复wxml引用wxs变量名t和template模板相关变量冲突导致无法正常渲染问题
Browse files Browse the repository at this point in the history
  • Loading branch information
canfoo committed May 21, 2020
1 parent 375cb08 commit 716c335
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions packages/alita-core/src/extractWxCompFiles/extractWxmlFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ export const handleChanged = (info, finalJSPath) => {
// 如果只使用一个child 小程序会报递归, 然后就不渲染了
const subT = `
<template name="${name}">
<block wx:if="{{t.l(d)}}">{{d}}</block>
<${genericCompName} wx:elif="{{d.${genericCompDiuu}}}" diuu="{{d.${genericCompDiuu}}}" style="{{t.s(d.${genericCompDiuu}style)}}"/>
<block wx:if="{{_t.l(d)}}">{{d}}</block>
<${genericCompName} wx:elif="{{d.${genericCompDiuu}}}" diuu="{{d.${genericCompDiuu}}}" style="{{_t.s(d.${genericCompDiuu}style)}}"/>
<template wx:elif="{{d.tempName}}" is="{{d.tempName}}" data="{{...d}}"/>
<block wx:else>
<block wx:for="{{d}}" wx:key="key">
<block wx:if="{{t.l(item)}}">{{item}}</block>
<${genericCompName} wx:elif="{{item.${genericCompDiuu}}}" diuu="{{item.${genericCompDiuu}}}" style="{{t.s(item.${genericCompDiuu}style)}}"/>
<block wx:if="{{_t.l(item)}}">{{item}}</block>
<${genericCompName} wx:elif="{{item.${genericCompDiuu}}}" diuu="{{item.${genericCompDiuu}}}" style="{{_t.s(item.${genericCompDiuu}style)}}"/>
<template wx:else is="{{item.tempName}}" data="{{...item}}"/>
</block>
</block>
Expand All @@ -97,7 +97,7 @@ export const handleChanged = (info, finalJSPath) => {

const utilWxsPath = `${RootPrefixPlaceHolader}/commonwxs.wxs`

templateWxml = `<wxs src="${utilWxsPath}" module="t" />
templateWxml = `<wxs src="${utilWxsPath}" module="_t" />
${templateWxml}
Expand Down
10 changes: 5 additions & 5 deletions packages/alita-core/src/tran/geneAllTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function(ast, info) {
const styleAttr = getAttr(jsxOp, 'style')
if (!styleAttr) {
jsxOp.attributes.push(
t.jsxAttribute(t.jsxIdentifier('style'), t.stringLiteral(`{{t.s(${diuuKey}style)}}`))
t.jsxAttribute(t.jsxIdentifier('style'), t.stringLiteral(`{{_t.s(${diuuKey}style)}}`))
)
}

Expand All @@ -130,7 +130,7 @@ export default function(ast, info) {


jsxOp.attributes.push(
t.jsxAttribute(t.jsxIdentifier('style'), t.stringLiteral(`{{t.s(${diuuKey}style)}}`))
t.jsxAttribute(t.jsxIdentifier('style'), t.stringLiteral(`{{_t.s(${diuuKey}style)}}`))
)
jsxOp.attributes.push(
t.jsxAttribute(t.jsxIdentifier('wx:if'), t.stringLiteral(`{{${diuuKey}style !== false}}`)),
Expand Down Expand Up @@ -199,7 +199,7 @@ export default function(ast, info) {
jsxOp.attributes = jsxOp.attributes.filter(attr => !(attr.type === 'JSXAttribute' && attr.name.name === 'style'))

jsxOp.attributes.push(
t.jsxAttribute(t.jsxIdentifier('style'), t.stringLiteral(`{{t.s(${diuuKey}style)}}`))
t.jsxAttribute(t.jsxIdentifier('style'), t.stringLiteral(`{{_t.s(${diuuKey}style)}}`))
)

if (info.isPageComp) {
Expand Down Expand Up @@ -251,7 +251,7 @@ export default function(ast, info) {
// 微信基本组件 <view style="height: 90px"/>
return
} else {
attr.value = t.stringLiteral(`{{t.s(${diuuKey}style)}}`)
attr.value = t.stringLiteral(`{{_t.s(${diuuKey}style)}}`)
}
return
}
Expand Down Expand Up @@ -281,7 +281,7 @@ export default function(ast, info) {
// 微信基本组件 <view style="height: 90px"/>
return
} else {
attr.value = t.stringLiteral(`{{t.s(${diuuKey}style)}}`)
attr.value = t.stringLiteral(`{{_t.s(${diuuKey}style)}}`)
}
return
}
Expand Down

0 comments on commit 716c335

Please sign in to comment.