vue-v-model 常用修饰符

2022年12月9日10:56:21
<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 常用修饰符

  • 作者:@大熊
  • 原文链接:https://blog.csdn.net/qq_51558433/article/details/118391099
    更新时间:2022年12月9日10:56:21 ,共 525 字。