小工具知识网

当前位置: 首页 > 行业知识 > vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题

行业知识

vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题

2026-11-16 01:08:31 来源:互联网转载

 当我想对获取到的数据字典进行一些操作的时候发现我在setup语法糖里面没办法对这个数据进行相关的操作

//接收到的camera_scene_location是响应式的const {camera_scene_location} = UseDict('camera_scene_location');// 打印输出camera_scene_location.valueconsole.log(camera_scene_location)console.log(camera_scene_location.value)

后面研究了一下应该和异步有关系,从这个字典获取到的数据是异步的,拿不到里面的数据!但是我搞不懂为啥打印的时候不带.value就可以打印出来

后面用watch监听这个数据就可以打印出来

   watch(      () => camera_scene_location.value,      () => {       console.log(camera_scene_location.value);      },      { deep: true }    );

上一篇:不花钱也能实现大屏梦想,零成本电视投屏指南!

下一篇:杜比服务器管理系统怎么用?