zoukankan      html  css  js  c++  java
  • Vue中props类型及默认值

     props: {
        demoString: {
          type: String,
          default: ''
        },
        demoNumber: {
          type: Number,
          default: 0
        },
        demoBoolean: {
          type: Boolean,
          default: true
        },demoArray: {
          type: Array,
          default: () => []
        },
        demoObject: {
          type: Object,
          default: () => ({})
        },
        demoFunction: {
          type: Function,
          default: function () { }
        }
      }

    其中,默认值为对象时
    不能写成

    demoObject: {
          type: Object,
          default: () => { }
        }

    不加’()'的话返回的是一个空函数体,没有返回值。
    默认写法

    demoObject: {
          type: Object,
          default: function () {
            return {}
          }
        }

    订阅专栏  props: {    demoString: {      type: String,      default: ''    },    demoNumber: {      type: Number,      default: 0    },    demoBoolean: {      type: Boolean,      default: true    },    demoArray: {      type: Array,      default: () => []    },    demoObject: {      type: Object,      default: () => ({})    },    demoFunction: {      type: Function,      default: function () { }    }  }1234567891011121314151617181920212223242526其中,默认值为对象时不能写成
        demoObject: {      type: Object,      default: () => { }    }1234不加’()'的话返回的是一个空函数体,没有返回值。默认写法
        demoObject: {      type: Object,      default: function () {        return {}      }    }————————————————版权声明:本文为CSDN博主「zhangyiyy」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/weixin_39457424/article/details/105289303

  • 相关阅读:
    用SQL查询方式显示GROUP BY中的TOP解决方法[转]
    三大UML建模工具Visio、Rational Rose、PowerDesign的区别
    Eclipse HTML Editor
    [转]跨平台开发:PhoneGap移动开发框架初探
    取消开机显示登陆页面
    PhoneGap开发环境搭建
    显示器不能全屏及开机慢解决方案
    调用webservice超时问题的解决[转]
    最简单的JAVA解析XML字符串方法
    适用于vue项目的打印插件(转载)
  • 原文地址:https://www.cnblogs.com/mmzuo-798/p/15188014.html
Copyright © 2011-2022 走看看