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

03-21 阅读 0评论

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

vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题,vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,前端,操作,关系,第1张
(图片来源网络,侵删)
//接收到的camera_scene_location是响应式的
const {camera_scene_location} = UseDict('camera_scene_location');
// 打印输出camera_scene_location.value
console.log(camera_scene_location)
console.log(camera_scene_location.value)

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

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

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

   watch(
      () => camera_scene_location.value,
      () => {
       console.log(camera_scene_location.value);
      },
      { deep: true }
    );
vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题,vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,前端,操作,关系,第3张
(图片来源网络,侵删)
vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题,vue3响应式ref console.log输出.value时数据为空直接输出则显示数据 前端异步问题,词库加载错误:未能找到文件“C:\Users\Administrator\Desktop\火车头9.8破解版\Configuration\Dict_Stopwords.txt”。,前端,操作,关系,第4张
(图片来源网络,侵删)

免责声明
本网站所收集的部分公开资料来源于AI生成和互联网,转载的目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
评论列表 (暂无评论,人围观)

还没有评论,来说两句吧...

目录[+]