<! DOCTYPE html >
< html lang = " en" > < head> < meta charset = " UTF-8" > < meta name = " viewport" content = " width=device-width, initial-scale=1.0" > < title> Vue 3 回车键示例</ title> < script src = " https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.min.js" > </ script> < link rel = " stylesheet" href = " https://cdn.jsdelivr.net/npm/element-plus@2.3.9/dist/index.min.css" > < script src = " https://cdn.jsdelivr.net/npm/element-plus@2.3.9/dist/index.full.min.js" > </ script> </ head> < body> < div id = " app" > < el-form :model = " UserMage" label-width = " 120px" > < el-form-item label = " " > 用户名:< el-input v-model = " username" auto-complete = " off" placeholder = " 请输入用户名" size = " large" @keyup.enter.native = " focusInput" /> </ el-form-item> < el-form-item label = " " > 密码:< el-input v-model = " password" auto-complete = " off" placeholder = " 请输入密码" size = " large" show-password ref = " barcodepwd" /> </ el-form-item> </ el-form> </ div> < script> const { reactive, ref, toRefs, createApp, } = Vue; const vue3Composition = { setup ( ) { const UserMage = reactive ( { username : '' , password : '' , } ) ; const barcodepwd = ref ( null ) ; const focusInput = ( ) => { barcodepwd. value. focus ( ) ; } const onSubmit = ( ) => { console. log ( '提交!' ) ; } ; const UserMageRefs = toRefs ( UserMage) ; return { UserMage, ... UserMageRefs, onSubmit, barcodepwd, focusInput, } } } ; createApp ( vue3Composition) . use ( ElementPlus) . mount ( "#app" ) ; </ script> </ body> </ html>