Form binding in Vue (3-11)

Form binding in Vue

You can use v-model to bind the value of the form.
There is also a usage of v-model which is v-model.
For example: v-model.trim is to remove the space before and after the data.
v-model.lazy is the cursor.
You can also use a listener to monitor data.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='./vue.js'></script>
</head>
<body>
    <div id="root">
      <!-- <input type="radio" value="test" v-model="value"/> -->
      <input type="text" v-model.lazy="value"/>
      <!-- <select v-model="value">
          <option disabled>--请选择--</option>
          <option value='1'>A</option>
          <option value='2'>B</option>
          <option value='3'>C</option>
      </select> -->
      <!-- <textarea v-model="value"></textarea> -->
      {
   
   {value}}
    </div>    
    <script>
        // self要求,clicl事件只有在e.target = e.currentTaget的时候才会执行
        var vm = new Vue({
     
     
            el: "#root",
            data: {
     
     
                value: ""
            },
            watch: {
     
     
                value: function() {
     
     
                    console.log(typeof this
                    .value)
                }
            }
        })
    </script>
</body>
</html>

Guess you like

Origin blog.csdn.net/weixin_45647118/article/details/113927029