美文网首页
vue 3 computed 使用异步函数,使用computed

vue 3 computed 使用异步函数,使用computed

作者: 冰落寞成 | 来源:发表于2023-04-25 10:40 被阅读0次

用于computed 计算一个异步函数的返回值

computed 不支持。可以使用computedAsync[https://vueuse.org/core/computedAsync/]

import { ref } from 'vue'
import { computedAsync } from '@vueuse/core'

const name = ref('jack')

const userInfo = computedAsync(
  async () => {
    return await mockLookUp(name.value)
  },
  null, // initial state
)

相关文章

网友评论

      本文标题:vue 3 computed 使用异步函数,使用computed

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