ByteNote LogoByteNote

Navigation

  • Blog
  • 工具

    © 2025 ByteNote. All rights reserved.

    Vue3 Ref 组件类型定义

    Jul 4, 202212 min read
    <!-- Home.vue -->
    <template>
      <MyForm :ref="$form" />
    </template>
    
    <script>
    import { defineComponent, ref, onMounted } from '@vue/runtime-core'
    import MyForm, { MyFormExpose } from '@/components/MyForm'
    export default defineComponent({
      components: { MyForm }
      
      setup(){
        const $form = ref<InstanceType<typeof MyForm> & MyFormExpose>(null)
        
        onMounted(() => {
           $form?.value.validate // 类型正确
        })
      }
    })
    </script>
    

    相关文章

    什么是CPI(消费者价格指数)?

    CPI是衡量消费者购买的一篮子商品和服务价格变动,用于评估通货膨胀和指导经济政策的指标。

    leaflet 如何修改默认选择的点位的颜色

    在 leaflet 中,通过设置 `style` 对象的 `color` 和 `fillColor` 属性来修改默认选择的点位的边框和填充颜色。

    Vue3 获取 DOM节点对象

    Vue 3.0通过`ref`和生命周期钩子`onMounted`或`nextTick`获取单个或多个DOM节点对象。

    Flutter pasteboard 使用示范

    Flutter pasteboard usage demonstration.

    解决 You should only use GetX or Obx for the specific widget that will be updated

    错误提示表明在使用Flutter的GetX库时,应仅对需要更新的特定小部件使用Obx或GetX,并且必须在该小部件的作用域内插入可观察变量,否则会导致错误。