Skip to content

Commit 7d5d35e

Browse files
committed
fix: classic data & computed support
1 parent 4dbddb7 commit 7d5d35e

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

packages/app-backend/src/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,6 @@ function getInternalInstanceChildren (instance) {
380380
if (instance.$children) {
381381
return instance.$children
382382
}
383-
console.log(instance.subTree.children)
384383
if (Array.isArray(instance.subTree.children)) {
385384
return instance.subTree.children.filter(vnode => !!vnode.component).map(vnode => vnode.component)
386385
}
@@ -769,13 +768,18 @@ function processState (instance) {
769768
const getters =
770769
type.vuex &&
771770
type.vuex.getters
771+
const computedDefs = type.computed
772772

773-
const data = instance._data || instance.renderContext || {}
773+
const data = instance._data || {
774+
...instance.data,
775+
...instance.renderContext
776+
} || {}
774777

775778
return Object.keys(data)
776779
.filter(key => (
777780
!(props && key in props) &&
778-
!(getters && key in getters)
781+
!(getters && key in getters) &&
782+
!(computedDefs && key in computedDefs)
779783
))
780784
.map(key => ({
781785
key,
@@ -825,7 +829,7 @@ function processComputed (instance) {
825829
computedProp = {
826830
type,
827831
key,
828-
value: instance[key]
832+
value: instance.renderContext ? instance.renderContext[key] : instance[key]
829833
}
830834
} catch (e) {
831835
computedProp = {

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
<script>
2-
import { ref } from 'vue'
2+
import { ref, computed } from 'vue'
33
44
export default {
55
name: 'Child',
66
77
setup () {
88
const answer = ref(42)
99
10+
const doubleAnswer = computed(() => answer.value * 2)
11+
12+
return {
13+
answer,
14+
doubleAnswer
15+
}
16+
},
17+
18+
data () {
1019
return {
11-
answer
20+
classicAnswer: 42
21+
}
22+
},
23+
24+
computed: {
25+
classicDoubleAnswer () {
26+
return this.classicAnswer * 2
1227
}
1328
}
1429
}
1530
</script>
1631

1732
<template>
1833
<div>
19-
Child: {{ answer }}
34+
Child: {{ answer }} x2: {{ doubleAnswer }}
2035
</div>
2136
</template>

0 commit comments

Comments
 (0)