直接操作DOM元素
This commit is contained in:
+23
-7
@@ -1,11 +1,27 @@
|
|||||||
<script setup lang="ts"></script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<h1>You did it!</h1>
|
<div>
|
||||||
<p>
|
<p>姓名:<input ref="name" /></p>
|
||||||
Visit <a href="https://vuejs.org/" target="_blank" rel="noopener">vuejs.org</a> to read the
|
<button @click="showRef">提交</button>
|
||||||
documentation
|
</div>
|
||||||
</p>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
|
||||||
|
let name = ref()
|
||||||
|
|
||||||
|
// 获取DOM元素,直接操作DOM
|
||||||
|
function showRef(){
|
||||||
|
console.log(name)
|
||||||
|
console.log("=====================")
|
||||||
|
console.log(name.value)
|
||||||
|
console.log("=====================")
|
||||||
|
console.log(name.value.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
Reference in New Issue
Block a user