当前位置: 首页 > news >正文

vue3-模板引用

//1.调用ref函数 -> ref对象
const h1Ref = ref(null)
const comRef = ref(null)
//组件挂载完毕之后才能获取
onMounted(()=>{console.log(h1Ref.value);console.log(comRef.value);
})
  <div class="father"><!-- 通过ref标识绑定ref对象 --><h2 ref="h1Ref">父组件</h2><HelloWorldVue :count="count" message="father message" @get-message="getMessage" ref="comRef"></HelloWorldVue></div>

绑定之后结果

在这里插入图片描述
默认情况下在

子组件中

const name = ref('test name')
defineExpose({name
})

在这里插入图片描述

http://www.lryc.cn/news/283940.html

相关文章:

  • 聚类模型评估指标
  • 测试 ASP.NET Core 中间件
  • 智能小程序小部件(Widget)媒体组件属性说明和示例代码汇总
  • enum的比较
  • 网工每日一练(1月15日)
  • henauOJ 1113: 计算x的n次方
  • 64.Spring事件监听的核心机制是什么?
  • 《C++大学教程》3.12Account类
  • 【工作记录】基于springboot3+springsecurity实现多种方式登录及鉴权(二)
  • CSS笔记III
  • Bit.Store 加密卡集成主流 BRC20通证,助力 BTC 生态流动性
  • openssl3.2 - 官方demo学习 - mac - siphash.c
  • (六)深入理解Bluez协议栈之“GATT Client Profile”
  • SVO编译
  • 探索未知:最新发布的顶级浏览器,为你带来前所未有的浏览体验
  • EasyX图形化学习(三)
  • git-生成证书、公钥、私钥、error setting certificate verify locations解决方法
  • 论文笔记(四十)Goal-Auxiliary Actor-Critic for 6D Robotic Grasping with Point Clouds
  • k8s学习-Deployment
  • Unity之四元数
  • 【计算机硬件】3、输入输出技术、总线结构
  • k8s的对外服务--ingress
  • CSS 雷达监测效果
  • C# System.MissingMethodException
  • Redis面试题23
  • Linux中的yum源仓库和NFS文件共享服务
  • 【LeetCode2744】最大字符串配对数目
  • 安全加速SCDN是什么
  • Android 布局菜鸟 android中的布局类型和特点?
  • 2023总结与2024寒假计划