vue3怎么使用reactive赋值

使用ref赋值:

const list = ref([])
const getList = async () => {
  const res = await axios.get('/list')
  list.value = res.data
}

如何使用reactive来替换呢?

//const list = ref([])
const list = reactive([])
const getList = async () => {
  const res = await axios.get('/list')
  // list.value = res.data
  list.push(...res.data)
}

vue3使用proxy,对于对象和数组都不能直接整个赋值,那如何赋值呢?

相关推荐

  1. vue3 #ref #reactive

    2024-03-24 13:34:02       48 阅读
  2. ref&reactive vue3

    2024-03-24 13:34:02       36 阅读
  3. vue3 reactive

    2024-03-24 13:34:02       40 阅读
  4. Vue3 中应该使用 Ref 还是 Reactive

    2024-03-24 13:34:02       59 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-24 13:34:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-24 13:34:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-03-24 13:34:02       82 阅读
  4. Python语言-面向对象

    2024-03-24 13:34:02       91 阅读

热门阅读

  1. SpringBoot全局异常处理方法

    2024-03-24 13:34:02       40 阅读
  2. 【Node.js】events

    2024-03-24 13:34:02       44 阅读
  3. 【jvm】young gc full gc

    2024-03-24 13:34:02       33 阅读
  4. Python爬虫之urllib库

    2024-03-24 13:34:02       31 阅读
  5. 游戏中线上已有功能迭代的兼容问题

    2024-03-24 13:34:02       36 阅读
  6. Python爬虫之requests库

    2024-03-24 13:34:02       41 阅读
  7. LeetCode热题Hot100-两数之和

    2024-03-24 13:34:02       40 阅读
  8. centos配置natapp 自动配置

    2024-03-24 13:34:02       42 阅读
  9. Vue3组件之间通信方式

    2024-03-24 13:34:02       48 阅读