<template>
  <div>
    <input type='text' v-model='inputValue' @change='handleChange'>
  </div>
</template>
<script>
export default {
  data() {
    return {
      inputValue: ''
    }
  },
  methods: {
    handleChange() {
      console.log(this.inputValue)
    }
  }
}
</script>
<p>在上面的例子中,当输入框的值发生变化时,会触发 change 事件,并调用 handleChange 方法,通过 this.inputValue 来获取输入框的值。</p>
Vue.js 中如何使用 v-model 获取输入框的值

原文地址: http://www.cveoy.top/t/topic/oCK5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录