Skip to content

attached

ts
import { defineComponent, attached } from '@52css/mp-vue3'

defineComponent({
  properties: {},
  setup() {
    attached(() => {
      console.log("🚀 ~ attached ~ attached:", attached)
    })
  }
});

销毁

  • ✨ 返回函数,支持detached销毁
ts
import { defineComponent, attached } from '@52css/mp-vue3'

defineComponent({
  properties: {},
  setup() {
    attached(() => {
      let count = 0;
      let timer = setInterval(() => {
        console.log(count++)
      }, 1000)
      return () => {
        clearInterval(timer)
      }
    })
  }
});