Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
r15132706585
uni-app
提交
995e02f7
U
uni-app
项目概览
r15132706585
/
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,发现更多精彩内容 >>
提交
995e02f7
编写于
6月 23, 2022
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(App): slot name dynamic data (question/95109)
上级
bbb5f3af
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
22 addition
and
0 deletion
+22
-0
packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
...late-compiler/__tests__/compiler-app-plus.service.spec.js
+4
-0
packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
...emplate-compiler/__tests__/compiler-app-plus.view.spec.js
+4
-0
packages/uni-template-compiler/lib/app/parser/base-parser.js
packages/uni-template-compiler/lib/app/parser/base-parser.js
+8
-0
packages/uni-template-compiler/lib/app/service.js
packages/uni-template-compiler/lib/app/service.js
+2
-0
packages/uni-template-compiler/lib/app/util.js
packages/uni-template-compiler/lib/app/util.js
+2
-0
packages/uni-template-compiler/lib/app/view.js
packages/uni-template-compiler/lib/app/view.js
+2
-0
未找到文件。
packages/uni-template-compiler/__tests__/compiler-app-plus.service.spec.js
浏览文件 @
995e02f7
...
...
@@ -178,6 +178,10 @@ describe('codegen', () => {
'
<div><slot name="one"></slot></div>
'
,
`with(this){return _c('div',[_t("one",null,{"_i":1})],2)}`
)
assertCodegen
(
'
<div><slot :name="one"></slot></div>
'
,
`with(this){return _c('div',[_t(_$s(1,'name',one),null,{"_i":1})],2)}`
)
})
it
(
'
generate slot fallback content
'
,
()
=>
{
...
...
packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
浏览文件 @
995e02f7
...
...
@@ -178,6 +178,10 @@ describe('codegen', () => {
'
<div><slot name="one"></slot></div>
'
,
`with(this){return _c('div',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}`
)
assertCodegen
(
'
<div><slot :name="one"></slot></div>
'
,
`with(this){return _c('div',{attrs:{"_i":0}},[_t(_$g(1,'name'),null,{"_i":1})],2)}`
)
})
it
(
'
generate slot fallback content
'
,
()
=>
{
...
...
packages/uni-template-compiler/lib/app/parser/base-parser.js
浏览文件 @
995e02f7
...
...
@@ -2,6 +2,7 @@ const {
ID
,
C_IS
,
C_REF
,
C_NAME
,
V_IF
,
V_FOR
,
V_ELSE_IF
,
...
...
@@ -16,6 +17,12 @@ function parseRef (el, genVar) {
}
}
function
parseSlotName
(
el
,
genVar
)
{
if
(
el
.
slotName
&&
isVar
(
el
.
slotName
))
{
el
.
slotName
=
genVar
(
C_NAME
,
el
.
slotName
)
}
}
function
parseIs
(
el
,
genVar
)
{
if
(
!
el
.
component
)
{
return
...
...
@@ -106,6 +113,7 @@ function parseText (el, parent, state) {
module
.
exports
=
{
parseIs
,
parseRef
,
parseSlotName
,
parseIf
,
parseFor
,
parseText
,
...
...
packages/uni-template-compiler/lib/app/service.js
浏览文件 @
995e02f7
...
...
@@ -18,6 +18,7 @@ const {
const
{
parseIs
,
parseRef
,
parseSlotName
,
parseIf
,
parseFor
,
parseText
,
...
...
@@ -137,6 +138,7 @@ function transformNode (el, parent, state, isScopedSlot) {
parseIs
(
el
,
genVar
)
parseRef
(
el
,
genVar
)
parseSlotName
(
el
,
genVar
)
parseFor
(
el
,
createGenVar
,
isScopedSlot
,
checkAutoFill
(
el
))
parseKey
(
el
,
isScopedSlot
)
...
...
packages/uni-template-compiler/lib/app/util.js
浏览文件 @
995e02f7
...
...
@@ -15,6 +15,7 @@ const GET_CHANGE_DATA = '_$gc' // wxs
const
C_IS
=
'
is
'
const
C_SLOT_TARGET
=
'
st
'
const
C_REF
=
'
ref
'
const
C_NAME
=
'
name
'
const
V_FOR
=
'
f
'
const
V_IF
=
'
i
'
...
...
@@ -268,6 +269,7 @@ function addHandler (el, name, value, important) {
module
.
exports
=
{
C_IS
,
C_REF
,
C_NAME
,
V_FOR
,
V_IF
,
V_ELSE_IF
,
...
...
packages/uni-template-compiler/lib/app/view.js
浏览文件 @
995e02f7
...
...
@@ -13,6 +13,7 @@ const {
const
{
parseIs
,
parseRef
,
parseSlotName
,
parseIf
,
parseFor
,
parseText
,
...
...
@@ -130,6 +131,7 @@ function transformNode (el, parent, state, isScopedSlot) {
parseIs
(
el
,
genVar
)
parseRef
(
el
,
genVar
)
parseSlotName
(
el
,
genVar
)
if
(
parseFor
(
el
,
createGenVar
,
isScopedSlot
))
{
if
(
el
.
alias
[
0
]
===
'
{
'
)
{
// <div><li v-for=" { a, b } in items"></li></div>
el
.
alias
=
'
$item
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录