Vue props默认值

Vue props怎么定义函数默认值

发布 : Web前端培训   发布时间:2021-07-19 15:59:34

品牌型号:联想 YOGA 14c/系统版本:windows7

props 是VUE中子组件能获得父组件值得唯一通道,props可以给传进来得值进行默认值设置,以及他得类型

  1. props: {
  2. demoString: {
  3. type: String,
  4. default: ''
  5. },
  6. demoNumber: {
  7. type: Number,
  8. default: 0
  9. },
  10. demoBoolean: {
  11. type: Boolean,
  12. default: true
  13. },
  14. demoArray: {
  15. type: Array,
  16. default: () => []
  17. },
  18. demoObject: {
  19. type: Object,
  20. default: () => ({})
  21. },
  22. demoFunction: {
  23. type: Function,
  24. default: function () { }
  25. }

Vue props默认值
其它答案
牛仔很忙2020-06-22 18:56:36
  1. refArr: {
  2. type: Array,default: () => {return []
  3. }
  4. },
  5. refFun: {
  6. type: Function,default: () => () => {}
  7. },
  8. refObj: {
  9. type: Object,default: () => ({}) //这里是注意是括弧,必须是括弧。
  10. }

 相关推荐

 vue是什么软件

2021-07-19

 Vue props原理

2021-07-19

 Vue props默认值

2021-07-19

 Vue props用法

2021-07-19

 web服务器有哪些

2021-06-08