vue3中 ref 和 reactive 定义数组,赋值上的区别

2023-06-05  本文已影响0人  浅浅_2d5a

定义数组
const arr1 = ref([])
const arr2 = reactive([])
let state = reactive({
arr3 = []
})

接口返回值赋值 res.list
state.arr3 = res.list
arr2.push(...[res.list])
arr1.value = res.list

注意:
arr2 = res.list 这时候已经失去了响应式。需要使用push

上一篇 下一篇

猜你喜欢

热点阅读