小企业网站 优帮云,产品介绍网站源码,邯郸市旅游景点有哪些,平台推广策划方案实现过程#xff08;setup语法糖形式下#xff09;
在子组件完成方法逻辑#xff0c;并封装。在子组件中使用defineExpose暴露子组件的该方法。在父组件完成子组件ref的绑定。通过ref调用子组件暴露的方法。
子组件示例
template
/templatescript se…实现过程setup语法糖形式下
在子组件完成方法逻辑并封装。在子组件中使用defineExpose暴露子组件的该方法。在父组件完成子组件ref的绑定。通过ref调用子组件暴露的方法。
子组件示例
template
/templatescript setup
import { defineEmits } from vue;// 方法的定义
const contentIsEmpty () {uni.showModal({title: 请先完成${props.name}的输入,showCancel: false})
}// 暴露方法
defineExpose({contentIsEmpty
})
/scriptstyle langscss scoped
/style父组件示例
template!-- 绑定ref --ContentInput namexxx refcontentInputRef/
/templatescript setup// 导入组件import ContentInput from /components/content/content.vue;// 定义refconst contentInputRef ref(null)// 调用子组件所暴露的方法contentInputRef.value.contentIsEmpty()
/scriptstyle langscss scoped
/style