initial input item setp
This commit is contained in:
parent
8f90eeef9b
commit
b27b21d5d6
2 changed files with 50 additions and 6 deletions
42
src/components/UI/UIDetails/inputItem.vue
Normal file
42
src/components/UI/UIDetails/inputItem.vue
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<template>
|
||||
{{ input }}
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { defineComponent, ref, onUnmounted } from "vue";
|
||||
export default defineComponent({
|
||||
name: "InputItem",
|
||||
setup() {
|
||||
const input = ref("");
|
||||
|
||||
function handleInput(e) {
|
||||
const inputCode = e.keyCode;
|
||||
const cmd = String.fromCharCode(inputCode).toLowerCase();
|
||||
|
||||
switch(inputCode) {
|
||||
case 13:
|
||||
console.log('enter was pressed');
|
||||
break;
|
||||
case 8:
|
||||
console.log('delete was pressed');
|
||||
input.value = input.value.slice(0, -1);
|
||||
break;
|
||||
default:
|
||||
input.value += cmd;
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", handleInput);
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener("keydown", handleInput);
|
||||
})
|
||||
|
||||
return {
|
||||
input
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
@ -1,17 +1,19 @@
|
|||
<template>
|
||||
<UIindex />
|
||||
<Microphone />
|
||||
<!-- <UIindex />
|
||||
<Microphone /> -->
|
||||
<InputItem />
|
||||
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, onMounted } from 'vue';
|
||||
import UIindex from "@/components/UI/index.vue";
|
||||
import Microphone from "@/components/microphone/index.vue";
|
||||
import { defineComponent } from 'vue';
|
||||
// import UIindex from "@/components/UI/index.vue";
|
||||
// import Microphone from "@/components/microphone/index.vue";
|
||||
import InputItem from "@/components/UI/UIDetails/inputItem.vue";
|
||||
|
||||
export default defineComponent({
|
||||
name: "HomeIndex",
|
||||
components: { UIindex, Microphone },
|
||||
components: { InputItem },
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue