vue中input标签的使用

普通input标签

<input type="text" value="value" placeholder="placeholder" name="name">
  1. type

    规定 input 元素的类型,

  2. value

    规定 input 元素的值

  3. placeholder

    规定帮助用户填写输入字段的提示

  4. name

    1. 用于对提交到服务器后的表单数据进行标识
    2. 在客户端通过 JavaScript 引用表单数据

vue中的input标签

<input type="text" value="value" placeholder="placeholder" name="name" @input="print($event.target.value)">
<script>
export default {
  name:'login',
  methods:{
    print(e){
      console.log(e)
    }
  }
}
</script>
  1. 就是多了个@input事件,监听输入框中数值的变化
  2. $event.target.value可以获得输入框中的值
Logo

前往低代码交流专区

更多推荐