// 自己使用

<div v-for="item in ['lisi','wanger']" :key="item">
<test :ref="(el) => setGraphRef(el, item)" />
</div> const setGraphRef = (el, type) => {
if (el) {
itemRefs[type] = el;
}
}; // 调用
const targetRef = itemRefs[item];
if (targetRef) targetRef.testa();

// 官方的例子
<div v-for="item in list" :ref="setItemRef"></div> import { onBeforeUpdate, onUpdated } from "vue"; export default {
setup() {
let itemRefs = [];
const setItemRef = (el) => {
if (el) {
itemRefs.push(el);
}
};
onBeforeUpdate(() => {
itemRefs = [];
});
onUpdated(() => {
console.log(itemRefs);
});
return {
setItemRef,
};
},
};

最新文章

  1. Win 10 文件浏览器无法打开
  2. mapreduce性能提升2
  3. No.014 Longest Common Prefix
  4. OC使用inline替代宏
  5. BZOJ 3573 米特运输
  6. eclipse中英文切换--四种方式
  7. css3 content画出各种图形
  8. 解决larave-dompdf中文字体显示问题
  9. svn switch 的用法
  10. IOS 动画的两种方式
  11. 前端资讯周报 3.13 - 3.19: WebVR来了!以及如何优化scroll事件性能
  12. 浏览器css隐藏滚动条的方法!除了IE一般都支持
  13. JavaScript基础视频教程总结(111-120章)
  14. Python-HTML 最强标签分类
  15. (netty宝贵知识)
  16. [原创]K8飞刀20150720 新增Shellcode Loader支持多种格式
  17. Maven存储库
  18. 个人网站不输入www.直接domain.com访问不了,输入www.domain.com能访问
  19. Redis下载和安装
  20. Linux Namespace

热门文章

  1. DC-9靶场练习
  2. python操作MySQL数据库连接(pymysql)
  3. 使用docker中的MySQL
  4. A_A01_001 KEIL4-KEIL5软件安装
  5. Django TypeError at /login/ &#39;bool&#39; object is not callable
  6. S2-013 CVE-2013-1966
  7. C++Vector源码解析(侯捷STL)
  8. Stream中的常用方法_count-Stream中的常用方法_limit
  9. java helloworld demo
  10. .net core 阿里云接口之拷贝文件