Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
8aff183a
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8aff183a
编写于
7月 28, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp): $refs
上级
30362f36
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
125 addition
and
135 deletion
+125
-135
packages/uni-mp-alipay/dist/uni.mp.esm.js
packages/uni-mp-alipay/dist/uni.mp.esm.js
+6
-1
packages/uni-mp-baidu/dist/uni.mp.esm.js
packages/uni-mp-baidu/dist/uni.mp.esm.js
+14
-6
packages/uni-mp-core/src/runtime/componentInstance.ts
packages/uni-mp-core/src/runtime/componentInstance.ts
+5
-1
packages/uni-mp-core/src/runtime/util.ts
packages/uni-mp-core/src/runtime/util.ts
+26
-5
packages/uni-mp-qq/dist/uni.mp.esm.js
packages/uni-mp-qq/dist/uni.mp.esm.js
+14
-6
packages/uni-mp-toutiao/dist/uni.mp.esm.js
packages/uni-mp-toutiao/dist/uni.mp.esm.js
+14
-6
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+6
-60
packages/uni-mp-vue/lib/vue.runtime.esm.js
packages/uni-mp-vue/lib/vue.runtime.esm.js
+1
-22
packages/uni-mp-vue/src/plugin.ts
packages/uni-mp-vue/src/plugin.ts
+0
-14
packages/uni-mp-weixin/dist/uni.mp.esm.js
packages/uni-mp-weixin/dist/uni.mp.esm.js
+23
-6
packages/uni-quickapp-webview/dist/uni.mp.esm.js
packages/uni-quickapp-webview/dist/uni.mp.esm.js
+14
-6
packages/uni-shared/dist/uni-shared.d.ts
packages/uni-shared/dist/uni-shared.d.ts
+2
-2
未找到文件。
packages/uni-mp-alipay/dist/uni.mp.esm.js
浏览文件 @
8aff183a
...
...
@@ -258,7 +258,12 @@ function hasHook(name) {
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
...
...
packages/uni-mp-baidu/dist/uni.mp.esm.js
浏览文件 @
8aff183a
...
...
@@ -248,7 +248,12 @@ function hasHook(name) {
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
...
...
@@ -386,15 +391,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
packages/uni-mp-core/src/runtime/componentInstance.ts
浏览文件 @
8aff183a
...
...
@@ -211,7 +211,11 @@ function hasHook(this: ComponentPublicInstance, name: string) {
}
function
callHook
(
this
:
ComponentPublicInstance
,
name
:
string
,
args
?:
unknown
)
{
if
(
name
===
'
onLoad
'
&&
args
&&
(
args
as
any
).
__id__
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
)
// beforeMount
this
.
$
.
isMounted
=
true
name
=
'
m
'
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
(
args
as
any
).
__id__
)
{
;(
this
as
any
).
__eventChannel__
=
getEventChannel
((
args
as
any
).
__id__
)
delete
(
args
as
any
).
__id__
}
...
...
packages/uni-mp-core/src/runtime/util.ts
浏览文件 @
8aff183a
...
...
@@ -56,6 +56,31 @@ export function initWxsCallMethods(
})
}
function
selectAllComponents
(
mpInstance
:
MPComponentInstance
,
selector
:
string
,
$refs
:
Record
<
string
,
ComponentPublicInstance
>
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
)
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
$refs
[
ref
]
=
component
.
$vm
||
component
if
(
__PLATFORM__
===
'
mp-weixin
'
)
{
if
(
component
.
dataset
.
vueGeneric
===
'
scoped
'
)
{
component
.
selectAllComponents
(
'
.scoped-ref
'
)
.
forEach
((
scopedComponent
)
=>
{
selectAllComponents
(
scopedComponent
as
MPComponentInstance
,
selector
,
$refs
)
})
}
}
})
}
export
function
initRefs
(
instance
:
ComponentInternalInstance
,
mpInstance
:
MPComponentInstance
...
...
@@ -63,11 +88,7 @@ export function initRefs(
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
:
Record
<
string
,
any
>
=
{}
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
)
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
$refs
[
ref
]
=
component
.
$vm
||
component
})
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
)
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
)
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
...
...
packages/uni-mp-qq/dist/uni.mp.esm.js
浏览文件 @
8aff183a
...
...
@@ -248,7 +248,12 @@ function hasHook(name) {
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
...
...
@@ -386,15 +391,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
packages/uni-mp-toutiao/dist/uni.mp.esm.js
浏览文件 @
8aff183a
...
...
@@ -248,7 +248,12 @@ function hasHook(name) {
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
...
...
@@ -389,15 +394,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
8aff183a
import
{
isSymbol
,
extend
,
isMap
,
isObject
,
toRawType
,
def
,
isArray
,
isString
,
isFunction
,
isPromise
,
toHandlerKey
,
remove
,
EMPTY_OBJ
,
camelize
,
capitalize
,
normalizeClass
,
normalizeStyle
,
isOn
,
NOOP
,
isGloballyWhitelisted
,
isIntegerKey
,
hasOwn
,
hasChanged
,
invokeArrayFns
as
invokeArrayFns$1
,
makeMap
,
isSet
,
NO
,
toNumber
,
hyphenate
,
isReservedProp
,
EMPTY_ARR
,
toTypeString
}
from
'
@vue/shared
'
;
import
{
isSymbol
,
extend
,
isMap
,
isObject
,
toRawType
,
def
,
isArray
,
isString
,
isFunction
,
isPromise
,
toHandlerKey
,
remove
,
EMPTY_OBJ
,
camelize
,
capitalize
,
normalizeClass
,
normalizeStyle
,
isOn
,
NOOP
,
isGloballyWhitelisted
,
isIntegerKey
,
hasOwn
,
hasChanged
,
invokeArrayFns
,
makeMap
,
isSet
,
NO
,
toNumber
,
hyphenate
,
isReservedProp
,
EMPTY_ARR
,
toTypeString
}
from
'
@vue/shared
'
;
export
{
camelize
}
from
'
@vue/shared
'
;
const
invokeArrayFns
=
(
fns
,
arg
)
=>
{
let
ret
;
for
(
let
i
=
0
;
i
<
fns
.
length
;
i
++
)
{
ret
=
fns
[
i
](
arg
);
}
return
ret
;
};
const
ON_ERROR
=
'
onError
'
;
const
targetMap
=
new
WeakMap
();
...
...
@@ -3055,29 +3048,8 @@ const publicPropertiesMap = extend(Object.create(null), {
$options
:
i
=>
(
__VUE_OPTIONS_API__
?
resolveMergedOptions
(
i
)
:
i
.
type
),
$forceUpdate
:
i
=>
()
=>
queueJob
(
i
.
update
),
// $nextTick: i => nextTick.bind(i.proxy!), // fixed by xxxxxx
$watch
:
i
=>
(
__VUE_OPTIONS_API__
?
instanceWatch
.
bind
(
i
)
:
NOOP
),
// compat
$children
:
getCompatChildren
$watch
:
i
=>
(
__VUE_OPTIONS_API__
?
instanceWatch
.
bind
(
i
)
:
NOOP
)
});
function
getCompatChildren
(
instance
)
{
const
root
=
instance
.
subTree
;
const
children
=
[];
if
(
root
)
{
walk
(
root
,
children
);
}
return
children
;
}
function
walk
(
vnode
,
children
)
{
if
(
vnode
.
component
)
{
children
.
push
(
vnode
.
component
.
proxy
);
}
else
if
(
vnode
.
shapeFlag
&
16
/* ARRAY_CHILDREN */
)
{
const
vnodes
=
vnode
.
children
;
for
(
let
i
=
0
;
i
<
vnodes
.
length
;
i
++
)
{
walk
(
vnodes
[
i
],
children
);
}
}
}
const
PublicInstanceProxyHandlers
=
{
get
({
_
:
instance
},
key
)
{
const
{
ctx
,
setupState
,
data
,
props
,
accessCache
,
type
,
appContext
}
=
instance
;
...
...
@@ -3981,8 +3953,8 @@ const prodEffectOptions = {
function
createDevEffectOptions
(
instance
)
{
return
{
scheduler
:
queueJob
,
onTrack
:
instance
.
rtc
?
e
=>
invokeArrayFns
$1
(
instance
.
rtc
,
e
)
:
void
0
,
onTrigger
:
instance
.
rtg
?
e
=>
invokeArrayFns
$1
(
instance
.
rtg
,
e
)
:
void
0
onTrack
:
instance
.
rtc
?
e
=>
invokeArrayFns
(
instance
.
rtc
,
e
)
:
void
0
,
onTrigger
:
instance
.
rtg
?
e
=>
invokeArrayFns
(
instance
.
rtg
,
e
)
:
void
0
};
}
function
setupRenderEffect
(
instance
)
{
...
...
@@ -3998,7 +3970,7 @@ function setupRenderEffect(instance) {
const
{
bu
,
u
}
=
instance
;
// beforeUpdate hook
if
(
bu
)
{
invokeArrayFns
$1
(
bu
);
invokeArrayFns
(
bu
);
}
patch
(
instance
);
// updated hook
...
...
@@ -4012,7 +3984,7 @@ function unmountComponent(instance) {
const
{
bum
,
effects
,
update
,
um
}
=
instance
;
// beforeUnmount hook
if
(
bum
)
{
invokeArrayFns
$1
(
bum
);
invokeArrayFns
(
bum
);
}
if
(
effects
)
{
for
(
let
i
=
0
;
i
<
effects
.
length
;
i
++
)
{
...
...
@@ -4090,17 +4062,6 @@ function applyOptions(options, instance, publicThis) {
function
set
(
target
,
key
,
val
)
{
return
(
target
[
key
]
=
val
);
}
function
hasHook
(
name
)
{
const
hooks
=
this
.
$
[
name
];
if
(
hooks
&&
hooks
.
length
)
{
return
true
;
}
return
false
;
}
function
callHook
(
name
,
args
)
{
const
hooks
=
this
.
$
[
name
];
return
hooks
&&
invokeArrayFns
(
hooks
,
args
);
}
function
errorHandler
(
err
,
instance
,
info
)
{
...
...
@@ -4169,11 +4130,6 @@ function initApp(app) {
}
const
globalProperties
=
appConfig
.
globalProperties
;
uniIdMixin
(
globalProperties
);
{
// 小程序,待重构,不再挂靠全局
globalProperties
.
$hasHook
=
hasHook
;
globalProperties
.
$callHook
=
callHook
;
}
if
(
__VUE_OPTIONS_API__
)
{
globalProperties
.
$set
=
set
;
globalProperties
.
$applyOptions
=
applyOptions
;
...
...
@@ -4183,16 +4139,6 @@ function initApp(app) {
var
plugin
=
{
install
(
app
)
{
initApp
(
app
);
const
globalProperties
=
app
.
_context
.
config
.
globalProperties
;
const
oldCallHook
=
globalProperties
.
$callHook
;
globalProperties
.
$callHook
=
function
callHook
(
name
,
args
)
{
if
(
name
===
'
mounted
'
)
{
oldCallHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
return
oldCallHook
.
call
(
this
,
name
,
args
);
};
const
oldMount
=
app
.
mount
;
app
.
mount
=
function
mount
(
rootContainer
)
{
const
instance
=
oldMount
.
call
(
app
,
rootContainer
);
...
...
packages/uni-mp-vue/lib/vue.runtime.esm.js
浏览文件 @
8aff183a
...
...
@@ -3046,29 +3046,8 @@ const publicPropertiesMap = extend(Object.create(null), {
$options
:
i
=>
(
__VUE_OPTIONS_API__
?
resolveMergedOptions
(
i
)
:
i
.
type
),
$forceUpdate
:
i
=>
()
=>
queueJob
(
i
.
update
),
// $nextTick: i => nextTick.bind(i.proxy!), // fixed by xxxxxx
$watch
:
i
=>
(
__VUE_OPTIONS_API__
?
instanceWatch
.
bind
(
i
)
:
NOOP
),
// compat
$children
:
getCompatChildren
$watch
:
i
=>
(
__VUE_OPTIONS_API__
?
instanceWatch
.
bind
(
i
)
:
NOOP
)
});
function
getCompatChildren
(
instance
)
{
const
root
=
instance
.
subTree
;
const
children
=
[];
if
(
root
)
{
walk
(
root
,
children
);
}
return
children
;
}
function
walk
(
vnode
,
children
)
{
if
(
vnode
.
component
)
{
children
.
push
(
vnode
.
component
.
proxy
);
}
else
if
(
vnode
.
shapeFlag
&
16
/* ARRAY_CHILDREN */
)
{
const
vnodes
=
vnode
.
children
;
for
(
let
i
=
0
;
i
<
vnodes
.
length
;
i
++
)
{
walk
(
vnodes
[
i
],
children
);
}
}
}
const
PublicInstanceProxyHandlers
=
{
get
({
_
:
instance
},
key
)
{
const
{
ctx
,
setupState
,
data
,
props
,
accessCache
,
type
,
appContext
}
=
instance
;
...
...
packages/uni-mp-vue/src/plugin.ts
浏览文件 @
8aff183a
...
...
@@ -5,20 +5,6 @@ import { initApp } from '@dcloudio/uni-vue'
export
default
{
install
(
app
:
App
)
{
initApp
(
app
)
const
globalProperties
=
app
.
_context
.
config
.
globalProperties
const
oldCallHook
=
globalProperties
.
$callHook
globalProperties
.
$callHook
=
function
callHook
(
name
:
string
,
args
?:
unknown
)
{
if
(
name
===
'
mounted
'
)
{
oldCallHook
.
call
(
this
,
'
bm
'
)
// beforeMount
this
.
$
.
isMounted
=
true
name
=
'
m
'
}
return
oldCallHook
.
call
(
this
,
name
,
args
)
}
const
oldMount
=
app
.
mount
app
.
mount
=
function
mount
(
rootContainer
:
any
)
{
const
instance
=
oldMount
.
call
(
app
,
rootContainer
)
...
...
packages/uni-mp-weixin/dist/uni.mp.esm.js
浏览文件 @
8aff183a
...
...
@@ -185,7 +185,12 @@ function hasHook(name) {
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
...
...
@@ -323,15 +328,27 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
{
if
(
component
.
dataset
.
vueGeneric
===
'
scoped
'
)
{
component
.
selectAllComponents
(
'
.scoped-ref
'
)
.
forEach
((
scopedComponent
)
=>
{
selectAllComponents
(
scopedComponent
,
selector
,
$refs
);
});
}
}
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
packages/uni-quickapp-webview/dist/uni.mp.esm.js
浏览文件 @
8aff183a
...
...
@@ -248,7 +248,12 @@ function hasHook(name) {
return
false
;
}
function
callHook
(
name
,
args
)
{
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
if
(
name
===
'
mounted
'
)
{
callHook
.
call
(
this
,
'
bm
'
);
// beforeMount
this
.
$
.
isMounted
=
true
;
name
=
'
m
'
;
}
else
if
(
name
===
'
onLoad
'
&&
args
&&
args
.
__id__
)
{
this
.
__eventChannel__
=
getEventChannel
(
args
.
__id__
);
delete
args
.
__id__
;
}
...
...
@@ -386,15 +391,18 @@ function initWxsCallMethods(methods, wxsCallMethods) {
};
});
}
function
selectAllComponents
(
mpInstance
,
selector
,
$refs
)
{
const
components
=
mpInstance
.
selectAllComponents
(
selector
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
}
function
initRefs
(
instance
,
mpInstance
)
{
Object
.
defineProperty
(
instance
,
'
refs
'
,
{
get
()
{
const
$refs
=
{};
const
components
=
mpInstance
.
selectAllComponents
(
'
.vue-ref
'
);
components
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
$refs
[
ref
]
=
component
.
$vm
||
component
;
});
selectAllComponents
(
mpInstance
,
'
.vue-ref
'
,
$refs
);
const
forComponents
=
mpInstance
.
selectAllComponents
(
'
.vue-ref-in-for
'
);
forComponents
.
forEach
((
component
)
=>
{
const
ref
=
component
.
dataset
.
ref
;
...
...
packages/uni-shared/dist/uni-shared.d.ts
浏览文件 @
8aff183a
...
...
@@ -106,10 +106,10 @@ export declare const defaultRpx2Unit: {
declare
type
DictArray
=
[
number
,
number
][];
export
declare
class
EventChannel
{
id
:
number
;
id
?
:
number
;
private
listener
;
private
emitCache
;
constructor
(
id
:
number
,
events
?:
NavigateToOptionEvents
);
constructor
(
id
?
:
number
,
events
?:
NavigateToOptionEvents
);
emit
(
eventName
:
string
,
...
args
:
any
[]):
number
|
undefined
;
on
(
eventName
:
string
,
fn
:
EventChannelListener
[
'
fn
'
]):
void
;
once
(
eventName
:
string
,
fn
:
EventChannelListener
[
'
fn
'
]):
void
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录