vue-v-model 常用修饰符

15次阅读
没有评论
<div id="app">
    <h1>懒加载lazy</h1>
    <h3>不让输入框实时同步</h3>
    <input type="text" v-model.lazy="msg">
    <h2>{{msg}}</h2>
    <p>=========================================</p>
    <h1>number</h1>
    <h3>将输入的数字转换为数值型</h3>
    <!-- 因为客户端的内容都是字符串类型的 -->
    <input type="number" v-model.number="age">
    <h2>{{age}}==={{typeof(age)}}</h2>
    <p>=========================================</p>
    <h1>trim</h1>
    <h3>将输入的内容去掉首尾空格</h3>
    <input type="text" v-model.trim="name">
    <h2>==={{name}}===</h2>
  </div>
  <script>
    const app = Vue.createApp({ 
      data(){
        return{
           msg:"你好呀",
           age:1,
           name:"",
        }
      }
    }).mount("#app")
  </script>

vue-v-model 常用修饰符

正文完
 0