Vue Composition Api - 观看从外部组合函数导入的 属性

Vue Composition Api - watch property imported from external composition function

我有外部组合函数,我声明 属性 是这样的:

export default function useDescription() {
  const description = ref('');

  return {
    description
  }
}

然后,我想在其他组件中导入此 属性,在设置方法中并观察如下变化:

setup() {
  const { description } = useDescription();
  watch(description, (value) => {
    //do sth
  })
}

很遗憾,它不起作用。

删除函数外的 ref 属性 以便从两个组件都可以访问:

import { ref, watch } from "vue";
const description = ref("");
export default function useDescription() {
  return { description };
}

setup() {
  const { description } = useDescription();
  watch(()=>description, (value) => {
    //do sth
  })
}