美文网首页
vue中props的默认写法

vue中props的默认写法

作者: 秀萝卜 | 来源:发表于2020-04-26 13:06 被阅读0次
    props: {
        rowClick: {
          type: Function,
          default: function() {}
        },
        title: {
          type: String,
          default: "标题"
        },
        display: {
          type: String,
          default: "table" 
        },
        columnCount: {
          type: Number,
          default: 4
        },
        columns: {
          type: Array,
          default() {
            return [];
          }
        },
        showPage: {
          type: Boolean,
          default: true
        },
        api: {
          type: Object,
          default() {
            return {};
          }
        },
        parameter: {
          type: Object,
          default() {
            return {};
          }
        },
        defaultParameter: {
          type: Boolean,
          default() {
            return true;
          }
        }
      },
    

    注意:默认值类型为数组或对象,一定要在函数中返回这个默认值,而不是直接写

    正确:
    menu:{
         type:Array,
         default:function(){
             return []
         }
     }
    
    错误:
    menu:{
         type:Array,
         default:[]
     }
    

    相关文章

      网友评论

          本文标题:vue中props的默认写法

          本文链接:https://www.haomeiwen.com/subject/wjmdwhtx.html