Skip to content

Commit 8b2360e

Browse files
committed
feat(components): display refs
1 parent f70373a commit 8b2360e

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

packages/app-backend-vue3/src/components/data.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ async function getInstanceState (instance) {
2424
processComputed(instance),
2525
processAttrs(instance),
2626
processProvide(instance),
27-
processInject(instance)
27+
processInject(instance),
28+
processRefs(instance)
2829
)
2930
}
3031

@@ -248,6 +249,15 @@ function processInject (instance) {
248249
}))
249250
}
250251

252+
function processRefs (instance) {
253+
return Object.keys(instance.refs)
254+
.map(key => ({
255+
type: 'refs',
256+
key,
257+
value: instance.refs[key]
258+
}))
259+
}
260+
251261
export function editState ({ componentInstance, path, state }: HookPayloads[Hooks.EDIT_COMPONENT_STATE], ctx: BackendContext) {
252262
let target: any
253263
const targetPath: string[] = path.slice()

packages/shell-dev-vue3/src/Nested.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,29 @@ export default {
1111
type: Number,
1212
default: 4
1313
}
14+
},
15+
16+
data () {
17+
return {
18+
childRefs: []
19+
}
20+
},
21+
22+
beforeUpdate () {
23+
this.childRefs = []
1424
}
1525
}
1626
</script>
1727

1828
<template>
1929
<div>
20-
<h3>Nest children</h3>
30+
<h3 ref="title">
31+
Nest children
32+
</h3>
2133
<Child
2234
v-for="i in count"
2335
:key="i"
36+
:ref="target => target && childRefs.push(target)"
2437
/>
2538
<div>
2639
<Child

0 commit comments

Comments
 (0)