1. 程式人生 > 其它 >Vue props default Array 或者是Object 的正確寫法

Vue props default Array 或者是Object 的正確寫法

技術標籤:vuejavascripthtml

1.正確的寫法

props:{
   json:{
   type:Object,
   default:function(){
   return{};/return[];
           }
     }
  }
  

或用箭頭函式

props:{
json:{
type:Array,
default:()=>[]
}
}
props:{
json:{
type:Object,
default:()=>({})/default:()=>{return{};}
}
}