提示💡

ref 需要在顶级定义,异步赋值。

const loadData = async () => {
  try {
    //...
  } catch (error) {
    console.log(error)
  }
}
 
onMounted(async () => {
  let data = {}
  if (!!route.query.id) {
    data = await loadData()
  }
  Object.assign(form.value, data)
})
 
const { addContext } = useExpressionContext()
addContext(props.id, {
  form,
})