做网站需要什么配置,北京工信部网站备案查询,安徽省建设工程信息网站,设计网站 杭州vue3ts通过ref访问组件里面的方法及属性
之前访问不到主要是子组件没有往外暴露要访问的接口子组件使用了 script setup的组件是默认私有的#xff1a;一个父组件无法访问到一个使用了 script setup的子组件中的任何东西#xff0c;#xff1a; 除非子组件在其中通过 defin…vue3ts通过ref访问组件里面的方法及属性
之前访问不到主要是子组件没有往外暴露要访问的接口子组件使用了 script setup的组件是默认私有的一个父组件无法访问到一个使用了 script setup的子组件中的任何东西 除非子组件在其中通过 defineExpose方法 宏显式暴露 子组件
templatea-drawer v-model:openopen classcustom-class root-class-nameroot-class-name :root-style{ color: blue }titleBasic Drawer placementright/a-drawer
/template
script setup langts
import { ref } from vue;
const open ref(false);
const showDrawer () {open.value true;
};
defineExpose({showDrawer
})
/script父组件 ApiModel refrefApiModel/
import ApiModel from ./components/ApiModel.vue
const refApiModel:anyref(null)
const actionApiRecord(type:string,record:any){switch(type){case add:refApiModel.value?.showDrawer()break;}
}