You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
691 B
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<h1>{{title}}</h1>
<input ref="input" v-model="input" type="text">
<button @click="getVaule">获取值</button>
<div class="tip">F12console</div>
</div>
</template>
<script>
export default {
name:'GetValue',
data(){
return{
title:'这是GetValue组件',
input:'绑定的值',
}
},
methods:{
getVaule(){
console.log('这是ref获取的值'+this.$refs.input.value)
console.log('通过this去定义好的值'+this.input)
}
}
}
</script>
<style>
.tip{
background: red;
color: #fff;
margin-top: 10px;
}
</style>