关于输入框

监听输入

失去焦点的事件

<template>
  <div class="orderinfo">
 
  <input type="text" v-model="text" @blur="blur()">
  </div>
</template>


<script>
export default {
  name: "Orderinfo",
  data() {
    return {
      text:''
    };
  },

  mounted() {},
  watch: {
    // 监听输入框输入
    text: function(val) {
      if (val.length > 0) {
        console.log('显示删除')
      } else {
         console.log('不显示删除')
      }
    }
  },

  methods: {
    //失去焦点
    blur(){
      console.log(this.text)
    }
  }
};
</script>

<style scoped lang="scss">

</style>

 

Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐