Skip to content

Commit 24c809e

Browse files
fix: correct small bugs in the v-for array refs examples (#771)
1 parent 5192278 commit 24c809e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/guide/migration/array-refs.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export default {
2525
},
2626
methods: {
2727
setItemRef(el) {
28-
this.itemRefs.push(el)
28+
if (el) {
29+
this.itemRefs.push(el)
30+
}
2931
}
3032
},
3133
beforeUpdate() {
@@ -40,13 +42,15 @@ export default {
4042
With Composition API:
4143

4244
```js
43-
import { ref, onBeforeUpdate, onUpdated } from 'vue'
45+
import { onBeforeUpdate, onUpdated } from 'vue'
4446

4547
export default {
4648
setup() {
4749
let itemRefs = []
4850
const setItemRef = el => {
49-
itemRefs.push(el)
51+
if (el) {
52+
itemRefs.push(el)
53+
}
5054
}
5155
onBeforeUpdate(() => {
5256
itemRefs = []
@@ -55,7 +59,6 @@ export default {
5559
console.log(itemRefs)
5660
})
5761
return {
58-
itemRefs,
5962
setItemRef
6063
}
6164
}

0 commit comments

Comments
 (0)