render函數中如何綁定id和class和style和事件


使用attrs屬性就可以綁定id

render函數如何綁定class 使用關鍵字class

render函數如何綁定style 使用關鍵字 style

export default{
    data(){
        return{
        }
    },
    render(h){
        return h('div',{
          attrs:{
               id:"box"
           },
           class:{
               'demo':true
           },
           style:{
               'color':"red"
           },
        },
         "這是一個div元素"
       );
    }
}
// render函數中如何綁定一個事件
// on: {
//     'click': function(event) {
//         console.log(event)
//     }
// }


// render如何添加事件修飾符  ~  只會執行一次
// on: {
//     '~click': function(event) {
//         console.log(event)
//     }
// }

 
這下面的方法這一個沒有被實踐過  不知道
// on:{
//        'click':function(event){
//            event.stopPropgation();//阻止默認事件
//            event.stopPrevent();
//            event.target===event.target.current //點擊的當前元素
//        }
//    }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM