在render函数中如何实现v-model


export default{
    data(){
        return{
        }
    },
    render(h){
        let that=this;//为了防止this的指向发生改变
        console.log("render中的this", this);//Proxy {}对象
        return h('input',{
            // wa你想咋个命名就怎样
            wa:{
                value: that.value,//获取值
            },
            // 事件on,用来监听input事件
            on:{
                'input':function(event){
                    that.$emit('input',event.target.value)
                }
            }
        }
       );
    }
}

在使用的页面中

import aa from "./myrender"
  
   <aa v-model="name"></aa>
   {{name}}

  data(){
     return{
         name:"",
     }
  }

 components:{
     aa
 }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM