html中:
<div :ref="`Ref${index}`"></div>
script中:
import { getCurrentInstance } from "vue";
const ctx = getCurrentInstance();
需要使用动态ref的函数中:
ctx.refs[`Ref${index}`].function();
Vue3.0中如何动态设置ref
最新推荐文章于 2024-05-26 03:38:41 发布
html中:
<div :ref="`Ref${index}`"></div>
script中:
import { getCurrentInstance } from "vue";
const ctx = getCurrentInstance();
需要使用动态ref的函数中:
ctx.refs[`Ref${index}`].function();