Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
良好的行为成为习惯
uni-app
提交
8b892049
U
uni-app
项目概览
良好的行为成为习惯
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
8b892049
编写于
2月 13, 2020
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(v3): generate unique id
上级
66771b4f
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
47 addition
and
26 deletion
+47
-26
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+5
-5
packages/uni-app-plus/dist/service.runtime.esm.js
packages/uni-app-plus/dist/service.runtime.esm.js
+4
-6
packages/uni-app-plus/dist/view.umd.min.js
packages/uni-app-plus/dist/view.umd.min.js
+2
-2
src/platforms/app-plus/service/framework/plugins/data.js
src/platforms/app-plus/service/framework/plugins/data.js
+5
-2
src/platforms/app-plus/view/framework/plugins/vdom-sync.js
src/platforms/app-plus/view/framework/plugins/vdom-sync.js
+31
-11
未找到文件。
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
8b892049
...
...
@@ -297,10 +297,6 @@ var serviceContext = (function () {
return
(
''
+
str
).
replace
(
/
[^\x
00-
\x
ff
]
/g
,
'
**
'
).
length
}
function
guid
()
{
return
Math
.
floor
(
4294967296
*
(
1
+
Math
.
random
())).
toString
(
16
).
slice
(
1
)
}
function
debounce
(
fn
,
delay
)
{
let
timeout
;
return
function
()
{
...
...
@@ -12886,7 +12882,11 @@ var serviceContext = (function () {
this
.
_$vdomSync
=
new
VDomSync
(
this
.
$options
.
pageId
,
this
.
$options
.
pagePath
,
this
);
}
if
(
this
.
_$vd
)
{
this
.
_$id
=
guid
();
if
(
!
this
.
$parent
)
{
this
.
_$id
=
'
-1
'
;
}
else
{
this
.
_$id
=
this
.
$parent
.
_$id
+
'
,
'
+
this
.
$vnode
.
data
.
attrs
.
_i
;
}
this
.
_$vd
.
addVm
(
this
);
this
.
_$vdMountedData
=
Object
.
create
(
null
);
this
.
_$setData
(
MOUNTED_DATA
,
this
.
_$vdMountedData
);
...
...
packages/uni-app-plus/dist/service.runtime.esm.js
浏览文件 @
8b892049
...
...
@@ -5641,7 +5641,6 @@ function insertBefore() {
function
removeChild
(
node
,
child
)
{
if
(
child
&&
child
.
_$vd
)
{
// TODO 目前存储的 element 非树形,remove 的不干净(会遗留子节点)
child
.
_$vd
.
removeElement
(
child
);
}
}
...
...
@@ -6803,12 +6802,11 @@ function updateDOMListeners (oldVnode, vnode) {
target$1
=
vnode
.
elm
;
// fixed by xxxxxx 存储 vd
target$1
.
_$vd
=
vnode
.
context
.
_$vd
;
var
context
=
vnode
.
context
;
target$1
.
_$vd
=
context
.
_$vd
||
(
context
.
$root
&&
context
.
$root
.
_$vd
);
// 存储事件标记
target$1
.
setAttribute
(
'
nid
'
,
String
(
vnode
.
data
.
attrs
[
'
_i
'
]));
target$1
.
setAttribute
(
'
cid
'
,
context
.
_$id
||
vnode
.
data
.
cid
);
target$1
.
setAttribute
(
'
cid
'
,
context
.
_$id
);
normalizeEvents
(
on
);
updateListeners
(
on
,
oldOn
,
add$1
,
remove$2
,
createOnceHandler$1
,
vnode
.
context
);
...
...
packages/uni-app-plus/dist/view.umd.min.js
浏览文件 @
8b892049
此差异已折叠。
点击以展开。
src/platforms/app-plus/service/framework/plugins/data.js
浏览文件 @
8b892049
import
{
guid
,
hasOwn
,
isObject
,
camelize
...
...
@@ -88,7 +87,11 @@ export function initData (Vue) {
this
.
_$vdomSync
=
new
VDomSync
(
this
.
$options
.
pageId
,
this
.
$options
.
pagePath
,
this
)
}
if
(
this
.
_$vd
)
{
this
.
_$id
=
guid
()
if
(
!
this
.
$parent
)
{
this
.
_$id
=
'
-1
'
}
else
{
this
.
_$id
=
this
.
$parent
.
_$id
+
'
,
'
+
this
.
$vnode
.
data
.
attrs
.
_i
}
this
.
_$vd
.
addVm
(
this
)
this
.
_$vdMountedData
=
Object
.
create
(
null
)
this
.
_$setData
(
MOUNTED_DATA
,
this
.
_$vdMountedData
)
...
...
src/platforms/app-plus/view/framework/plugins/vdom-sync.js
浏览文件 @
8b892049
import
{
guid
}
from
'
uni-shared
'
import
{
VD_SYNC
,
UI_EVENT
}
from
'
../../../constants
'
function
findParentCid
(
vm
)
{
let
parent
=
vm
.
$parent
while
(
parent
)
{
if
(
parent
.
_$id
)
{
return
parent
.
_$id
}
parent
=
parent
.
$parent
}
}
export
class
VDomSync
{
constructor
(
pageId
)
{
this
.
pageId
=
pageId
this
.
addBatchVData
=
[]
this
.
addBatchVData
=
Object
.
create
(
null
)
this
.
updateBatchVData
=
[]
this
.
vms
=
Object
.
create
(
null
)
}
addVData
(
cid
,
data
=
{},
options
=
{})
{
this
.
addBatchVData
.
push
([
cid
,
data
,
options
])
this
.
addBatchVData
[
cid
]
=
[
data
,
options
]
}
updateVData
(
cid
,
data
=
{})
{
...
...
@@ -24,13 +30,22 @@ export class VDomSync {
}
initVm
(
vm
)
{
const
[
cid
,
data
,
options
]
=
this
.
addBatchVData
.
shift
()
if
(
!
cid
)
{
vm
.
_$id
=
guid
()
if
(
!
vm
.
$parent
)
{
vm
.
_$id
=
'
-1
'
}
else
{
vm
.
_$id
=
findParentCid
(
vm
)
+
'
,
'
+
vm
.
$vnode
.
data
.
attrs
.
_i
}
let
vData
=
this
.
addBatchVData
[
vm
.
_$id
]
if
(
!
vData
)
{
console
.
error
(
'
cid unmatched
'
,
vm
)
vData
=
{
data
:
{},
options
:
{}
}
}
else
{
vm
.
_$id
=
cid
delete
this
.
addBatchVData
[
vm
.
_$id
]
}
const
[
data
,
options
]
=
vData
Object
.
assign
(
vm
.
$options
,
options
)
vm
.
$r
=
data
||
Object
.
create
(
null
)
this
.
vms
[
vm
.
_$id
]
=
vm
...
...
@@ -50,7 +65,12 @@ export class VDomSync {
}
clearAddBatchVData
()
{
this
.
addBatchVData
.
length
=
0
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
Object
.
keys
(
this
.
addBatchVData
).
length
)
{
console
.
error
(
'
this.addBatchVData...=
'
+
JSON
.
stringify
(
this
.
addBatchVData
))
}
}
this
.
addBatchVData
=
Object
.
create
(
null
)
}
flush
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录