rubic icon indicating copy to clipboard operation
rubic copied to clipboard

Composable 中使用生命周期钩子提示当前没有实例 没法提取生命周期统一处理逻辑

Open hetao1024768 opened this issue 1 year ago • 1 comments

hetao1024768 avatar Oct 23 '23 09:10 hetao1024768

在 setup 中调用 composables。

import { defineComponent, onShow, ref } from 'rubic';

function useMessage() {
  const message = ref('');

  onShow(() => {
    setTimeout(() => {
      message.value = 'hello rubic';
    }, 2000);
  });

  return { message };
}

defineComponent({
  setup() {
    const { message } = useMessage();

    return {
      message,
    };
  },
});

guangzan avatar Nov 03 '23 02:11 guangzan