11<script setup>
22import { ref } from ' vue'
3- import { AppType , onThemeChange , watchLang } from ' @varlet/cli/client'
3+ import { AppType , onThemeChange , Snackbar , watchLang } from ' @varlet/cli/client'
44import { z } from ' zod'
55import { t , use } from ' ./locale'
66
@@ -18,6 +18,8 @@ const standardValue11 = ref('')
1818const standardValue12 = ref (' ' )
1919const standardValue13 = ref (' ' )
2020const standardValue14 = ref (' ' )
21+ const standardValue15 = ref (' ' )
22+ const standardValue16 = ref (' ' )
2123
2224const outlinedValue = ref (' ' )
2325const outlinedValue2 = ref (' ' )
@@ -34,6 +36,20 @@ const outlinedValue12 = ref('')
3436const outlinedValue13 = ref (' ' )
3537const outlinedValue14 = ref (' ' )
3638
39+ const inputRef = ref ()
40+
41+ const handleEnter = (value , e ) => {
42+ Snackbar .info (` 回车键被按下,当前值:${ value} ` )
43+ }
44+
45+ const handleKeydown = (e ) => {
46+ console .log (' keydown:' , e .key )
47+ }
48+
49+ const selectAll = () => {
50+ inputRef .value ? .select ()
51+ }
52+
3753watchLang (use)
3854onThemeChange ()
3955< / script>
@@ -78,6 +94,11 @@ onThemeChange()
7894 < var - input v- model= " standardValue10" : placeholder= " t('textarea')" textarea / >
7995 < var - input v- model= " standardValue11" : placeholder= " t('smallSize')" size= " small" / >
8096 < var - input v- model .trim = " standardValue12" : placeholder= " t('trim')" / >
97+ < var - input v- model= " standardValue15" : placeholder= " t('enterKey')" @enter= " handleEnter" @keydown= " handleKeydown" / >
98+ < var - space>
99+ < var - input ref= " inputRef" v- model= " standardValue16" : placeholder= " t('selectAll')" / >
100+ < var - button type= " primary" @click= " selectAll" > {{ t (' selectAllButton' ) }}< / var - button>
101+ < / var - space>
81102 < / var - space>
82103
83104 < app- type style= " margin-top: 10vmin" > {{ t (' outlined' ) }}< / app- type>
0 commit comments