Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yiicenne
uni-app
提交
593e6e8d
U
uni-app
项目概览
yiicenne
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
593e6e8d
编写于
3月 13, 2023
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mp): dynamic slot name with scopedSlotsCompiler: legacy
上级
b695a0c3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
3 deletion
+26
-3
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
...ni-template-compiler/__tests__/compiler-mp-alipay.spec.js
+11
-0
packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
...uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
+11
-0
packages/uni-template-compiler/lib/script/traverse/resolve-scoped-slots.js
...late-compiler/lib/script/traverse/resolve-scoped-slots.js
+2
-2
packages/uni-template-compiler/lib/template/traverse.js
packages/uni-template-compiler/lib/template/traverse.js
+2
-1
未找到文件。
packages/uni-template-compiler/__tests__/compiler-mp-alipay.spec.js
浏览文件 @
593e6e8d
...
...
@@ -105,6 +105,17 @@ describe('mp:compiler-mp-alipay', () => {
)
})
it
(
'
generate scoped slot with dynamic slot name
'
,
()
=>
{
assertCodegen
(
'
<view><slot :name="test" :user="user"></slot></view>
'
,
'
<view><slot name="{{test}}" user="{{user}}"></slot></view>
'
)
assertCodegen
(
'
<foo><template v-slot:[test]="{user}"><view>{{user}}</view></template></foo>
'
,
'
<foo vue-id="551070e6-1" onVueInit="__l" vue-slots="{{[test]}}"><view slot="{{test}}" slot-scope="__SCOPED__"><view>{{__SCOPED__.user}}</view></view></foo>
'
)
})
it
(
'
generate scoped slot with scopedSlotsCompiler: auto
'
,
()
=>
{
assertCodegen
(
'
<my-component><template v-slot="{item}">{{item}}<template></my-component>
'
,
...
...
packages/uni-template-compiler/__tests__/compiler-mp-baidu.spec.js
浏览文件 @
593e6e8d
...
...
@@ -81,6 +81,17 @@ describe('mp:compiler-mp-baidu', () => {
)
})
it
(
'
generate scoped slot with dynamic slot name
'
,
()
=>
{
assertCodegen
(
'
<view><slot :name="test" :user="user"></slot></view>
'
,
'
<view><slot name="{{test}}" var-user="user"></slot></view>
'
)
assertCodegen
(
'
<foo><template v-slot:[test]="{user}"><view>{{user}}</view></template></foo>
'
,
'
<foo vue-id="551070e6-1" vue-slots="{{[test]}}"><view slot="{{test}}"><view>{{user}}</view></view></foo>
'
)
})
it
(
'
generate scoped slot with scopedSlotsCompiler: auto
'
,
()
=>
{
assertCodegen
(
'
<my-component><template v-slot="{item}">{{item}}<template></my-component>
'
,
...
...
packages/uni-template-compiler/lib/script/traverse/resolve-scoped-slots.js
浏览文件 @
593e6e8d
...
...
@@ -124,9 +124,9 @@ module.exports = function getResolveScopedSlots (parent, state) {
updateIds
(
vueId
,
slotNode
,
params
.
node
.
name
)
}
const
fnBody
=
fn
.
get
(
'
value.body
'
)
//
暂不处理旧版编译模式对于动态 slotName 的处理,
含有动态 slotName 的情况下,scopedSlotsCompiler 指定使用增强编译模式
//
非原生支持作用域插槽的平台在
含有动态 slotName 的情况下,scopedSlotsCompiler 指定使用增强编译模式
const
isStaticSlotName
=
t
.
isStringLiteral
(
slotNode
)
if
(
state
.
options
.
scopedSlotsCompiler
===
'
augmented
'
||
needAugmentedSlotMode
(
fnBody
,
ids
,
state
)
||
!
isStaticSlotName
)
{
if
(
state
.
options
.
scopedSlotsCompiler
===
'
augmented
'
||
needAugmentedSlotMode
(
fnBody
,
ids
,
state
)
||
(
!
[
'
mp-baidu
'
,
'
mp-alipay
'
].
includes
(
state
.
options
.
platform
.
name
)
&&
!
isStaticSlotName
)
)
{
if
(
replaceId
(
fnBody
,
ids
))
{
const
test
=
t
.
callExpression
(
t
.
identifier
(
'
$hasSSP
'
),
[
vueId
])
// scopedSlotsCompiler auto
...
...
packages/uni-template-compiler/lib/template/traverse.js
浏览文件 @
593e6e8d
...
...
@@ -318,7 +318,8 @@ function traverseRenderSlot (callExprNode, state) {
}
deleteSlotName
=
props
.
SLOT_DEFAULT
&&
Object
.
keys
(
props
).
length
===
1
if
(
!
deleteSlotName
)
{
if
(
!
isStaticSlotName
)
{
// TODO 非原生支持作用域插槽的平台在未启用增强的模式下也允许使用动态插槽名
if
(
!
isStaticSlotName
&&
!
[
'
mp-baidu
'
,
'
mp-alipay
'
].
includes
(
state
.
options
.
platform
.
name
))
{
state
.
errors
.
add
(
uniI18n
.
__
(
'
templateCompiler.notSupportDynamicSlotName
'
,
{
0
:
'
v-slot
'
}))
return
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录