<template>
<h2>App</h2>
<input type="text" ref="txt" value="simple">
</template>
<script lang="ts">
// 引入子级组件Child
import { defineComponent, onMounted, ref, toRefs } from 'vue'
export default defineComponent({
name: 'App',
// 注册组件
setup() {
const txt=ref<HTMLElement|null>(null);
onMounted(() => {
console.log(txt.value);
//<input type='text'/>
txt.value && txt.value.focus()
})
return {
txt
}
},
})
</script>
02-09
2045
07-10
1114
12-11