Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
06fcd97d
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
06fcd97d
编写于
3月 23, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(v3): dynamic ref #1458
上级
48ec6ae4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
8 deletion
+35
-8
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
...ompiler/__tests__/compiler-app-plus-extra.service.spec.js
+7
-0
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
...e-compiler/__tests__/compiler-app-plus-extra.view.spec.js
+6
-0
packages/uni-template-compiler/lib/app/parser/base-parser.js
packages/uni-template-compiler/lib/app/parser/base-parser.js
+9
-1
packages/uni-template-compiler/lib/app/service.js
packages/uni-template-compiler/lib/app/service.js
+4
-2
packages/uni-template-compiler/lib/app/util.js
packages/uni-template-compiler/lib/app/util.js
+4
-1
packages/uni-template-compiler/lib/app/view.js
packages/uni-template-compiler/lib/app/view.js
+5
-4
未找到文件。
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.service.spec.js
浏览文件 @
06fcd97d
...
@@ -153,5 +153,12 @@ describe('codegen', () => {
...
@@ -153,5 +153,12 @@ describe('codegen', () => {
`with(this){return _c('base-layout',{attrs:{"_i":0},scopedSlots:_u([{key:_$s(1,'st',dynamicSlotName),fn:function(_empty_, _svm, _si){return undefined}}],null,true)})}`
`with(this){return _c('base-layout',{attrs:{"_i":0},scopedSlots:_u([{key:_$s(1,'st',dynamicSlotName),fn:function(_empty_, _svm, _si){return undefined}}],null,true)})}`
)
)
})
})
it
(
'
generate ref
'
,
()
=>
{
assertCodegen
(
'
<p :ref="component1"></p>
'
,
`with(this){return _c('p',{ref:_$s(0,'ref',component1)})}`
)
})
})
})
/* eslint-enable quotes */
/* eslint-enable quotes */
packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
浏览文件 @
06fcd97d
...
@@ -93,6 +93,12 @@ describe('codegen', () => {
...
@@ -93,6 +93,12 @@ describe('codegen', () => {
'
<base-layout><template v-slot:[dynamicSlotName]></template></base-layout>
'
,
'
<base-layout><template v-slot:[dynamicSlotName]></template></base-layout>
'
,
`with(this){return _c('base-layout',{attrs:{"_i":0},scopedSlots:_u([{key:_$g(1,'st'),fn:function(_empty_, _svm, _si){return undefined}}],null,true)})}`
`with(this){return _c('base-layout',{attrs:{"_i":0},scopedSlots:_u([{key:_$g(1,'st'),fn:function(_empty_, _svm, _si){return undefined}}],null,true)})}`
)
)
})
it
(
'
generate ref
'
,
()
=>
{
assertCodegen
(
'
<p :ref="component1"></p>
'
,
`with(this){return _c('p',{ref:_$g(0,'ref'),attrs:{"_i":0}})}`
)
})
})
})
})
/* eslint-enable quotes */
/* eslint-enable quotes */
packages/uni-template-compiler/lib/app/parser/base-parser.js
浏览文件 @
06fcd97d
const
{
const
{
ID
,
ID
,
C_IS
,
C_IS
,
C_REF
,
V_IF
,
V_IF
,
V_FOR
,
V_FOR
,
V_ELSE_IF
,
V_ELSE_IF
,
...
@@ -9,6 +10,12 @@ const {
...
@@ -9,6 +10,12 @@ const {
const
parseTextExpr
=
require
(
'
./text-parser
'
)
const
parseTextExpr
=
require
(
'
./text-parser
'
)
function
parseRef
(
el
,
genVar
)
{
if
(
el
.
ref
&&
isVar
(
el
.
ref
))
{
el
.
ref
=
genVar
(
C_REF
,
el
.
ref
)
}
}
function
parseIs
(
el
,
genVar
)
{
function
parseIs
(
el
,
genVar
)
{
if
(
!
el
.
component
)
{
if
(
!
el
.
component
)
{
return
return
...
@@ -97,7 +104,8 @@ function parseText (el, parent, state) {
...
@@ -97,7 +104,8 @@ function parseText (el, parent, state) {
}
}
module
.
exports
=
{
module
.
exports
=
{
parseIs
,
parseIs
,
parseRef
,
parseIf
,
parseIf
,
parseFor
,
parseFor
,
parseText
,
parseText
,
...
...
packages/uni-template-compiler/lib/app/service.js
浏览文件 @
06fcd97d
...
@@ -17,6 +17,7 @@ const {
...
@@ -17,6 +17,7 @@ const {
const
{
const
{
parseIs
,
parseIs
,
parseRef
,
parseIf
,
parseIf
,
parseFor
,
parseFor
,
parseText
,
parseText
,
...
@@ -130,6 +131,7 @@ function transformNode (el, parent, state, isScopedSlot) {
...
@@ -130,6 +131,7 @@ function transformNode (el, parent, state, isScopedSlot) {
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)
parseIs
(
el
,
genVar
)
parseIs
(
el
,
genVar
)
parseRef
(
el
,
genVar
)
parseFor
(
el
,
createGenVar
,
isScopedSlot
,
checkAutoFill
(
el
))
parseFor
(
el
,
createGenVar
,
isScopedSlot
,
checkAutoFill
(
el
))
parseKey
(
el
,
isScopedSlot
)
parseKey
(
el
,
isScopedSlot
)
...
@@ -162,10 +164,10 @@ function postTransformNode (el, options) {
...
@@ -162,10 +164,10 @@ function postTransformNode (el, options) {
}
else
{
}
else
{
options
.
root
=
el
options
.
root
=
el
}
}
traverseNode
(
el
,
false
,
{
traverseNode
(
el
,
false
,
{
createGenVar
,
createGenVar
,
forIteratorId
:
0
,
forIteratorId
:
0
,
transformNode
,
transformNode
,
filterModules
:
options
.
filterModules
filterModules
:
options
.
filterModules
})
})
optimize
(
el
,
options
)
optimize
(
el
,
options
)
...
...
packages/uni-template-compiler/lib/app/util.js
浏览文件 @
06fcd97d
...
@@ -13,6 +13,8 @@ const SET_MP_CLASS = '_$smc'
...
@@ -13,6 +13,8 @@ const SET_MP_CLASS = '_$smc'
const
GET_CHANGE_DATA
=
'
_$gc
'
// wxs
const
GET_CHANGE_DATA
=
'
_$gc
'
// wxs
const
C_IS
=
'
is
'
const
C_IS
=
'
is
'
const
C_SLOT_TARGET
=
'
st
'
const
C_REF
=
'
ref
'
const
V_FOR
=
'
f
'
const
V_FOR
=
'
f
'
const
V_IF
=
'
i
'
const
V_IF
=
'
i
'
...
@@ -208,7 +210,7 @@ function traverseNode (el, parent, state, isScopedSlot) {
...
@@ -208,7 +210,7 @@ function traverseNode (el, parent, state, isScopedSlot) {
state
.
childIndex
=
index
state
.
childIndex
=
index
slot
.
slotScope
=
`
${
slot
.
slotScope
}
, _svm, _si`
slot
.
slotScope
=
`
${
slot
.
slotScope
}
, _svm, _si`
if
(
slot
.
slotTargetDynamic
&&
slot
.
slotTarget
)
{
if
(
slot
.
slotTargetDynamic
&&
slot
.
slotTarget
)
{
slot
.
slotTarget
=
state
.
createGenVar
(
slot
.
attrsMap
[
ID
])(
'
st
'
,
slot
.
slotTarget
)
slot
.
slotTarget
=
state
.
createGenVar
(
slot
.
attrsMap
[
ID
])(
C_SLOT_TARGET
,
slot
.
slotTarget
)
}
}
traverseNode
(
slot
,
el
,
state
,
true
)
traverseNode
(
slot
,
el
,
state
,
true
)
})
})
...
@@ -256,6 +258,7 @@ function addHandler (el, name, value, important) {
...
@@ -256,6 +258,7 @@ function addHandler (el, name, value, important) {
module
.
exports
=
{
module
.
exports
=
{
C_IS
,
C_IS
,
C_REF
,
V_FOR
,
V_FOR
,
V_IF
,
V_IF
,
V_ELSE_IF
,
V_ELSE_IF
,
...
...
packages/uni-template-compiler/lib/app/view.js
浏览文件 @
06fcd97d
...
@@ -11,7 +11,8 @@ const {
...
@@ -11,7 +11,8 @@ const {
}
=
require
(
'
./util
'
)
}
=
require
(
'
./util
'
)
const
{
const
{
parseIs
,
parseIs
,
parseRef
,
parseIf
,
parseIf
,
parseFor
,
parseFor
,
parseText
,
parseText
,
...
@@ -126,7 +127,7 @@ function transformNode (el, parent, state, isScopedSlot) {
...
@@ -126,7 +127,7 @@ function transformNode (el, parent, state, isScopedSlot) {
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)
const
genVar
=
createGenVar
(
el
.
attrsMap
[
ID
],
isScopedSlot
)
parseIs
(
el
,
genVar
)
parseIs
(
el
,
genVar
)
parseRef
(
el
,
genVar
)
if
(
parseFor
(
el
,
createGenVar
,
isScopedSlot
))
{
if
(
parseFor
(
el
,
createGenVar
,
isScopedSlot
))
{
if
(
el
.
alias
[
0
]
===
'
{
'
)
{
// <div><li v-for=" { a, b } in items"></li></div>
if
(
el
.
alias
[
0
]
===
'
{
'
)
{
// <div><li v-for=" { a, b } in items"></li></div>
el
.
alias
=
'
$item
'
el
.
alias
=
'
$item
'
...
@@ -161,7 +162,7 @@ function postTransformNode (el, options) {
...
@@ -161,7 +162,7 @@ function postTransformNode (el, options) {
}
else
{
}
else
{
options
.
root
=
el
options
.
root
=
el
}
}
traverseNode
(
el
,
false
,
{
traverseNode
(
el
,
false
,
{
createGenVar
,
createGenVar
,
forIteratorId
:
0
,
forIteratorId
:
0
,
transformNode
,
transformNode
,
...
@@ -242,4 +243,4 @@ module.exports = {
...
@@ -242,4 +243,4 @@ module.exports = {
},
},
postTransformNode
,
postTransformNode
,
genData
genData
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录