美文网首页
vue3中 ref 和 reactive 定义数组,赋值上的区别

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

作者: 浅浅_2d5a | 来源:发表于2023-06-05 13:13 被阅读0次

定义数组
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

相关文章

网友评论

      本文标题:vue3中 ref 和 reactive 定义数组,赋值上的区别

      本文链接:https://www.haomeiwen.com/subject/soauedtx.html