Personal website click open

template

<input type="text" ref="inputRef" /> <! - plus colon incoming divs method -- -- > < div v - for = "I of three" : the key = "I" : ref = "divs" > < / div >Copy the code

setup

/ / get a dom const inputRef = ref < HTMLElement | null > (null); // Get multiple dom const arr = ref([]); Const divs = (el: HTMLElement) => {// Assert an Array of type HTMLElement (arr.value as Array<HTMLElement>).push(el); Argument of type 'HTMLElement' is not assignable to parameter of type 'never'. // arr.value.push(el); }; OnMounted (() => {// Input focus inputref.value && inputref.value.focus (); // Print multiple ref DOM console.log(arr); }); return { inputRef, divs, };Copy the code