zoukankan      html  css  js  c++  java
  • vue中props的默认写法

    1.默认写法

    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;
          }
        }
      },
    

    2.注意:
    如果默认值得类型为数组或者对象,一定要在函数中返回这个默认值,而不是直接写,否则报错

    正确:

     menu:{
         type:Array,
         default:function(){
             return []
         }
     }
    

    错误:

    menu:{
         type:Array,
         default:[]
     }
    

      

  • 相关阅读:
    最大流问题的几种经典解法综述
    有上下界的网络流
    hiho一下
    poj 1018
    状压dp
    hdu 1043
    Poj1015
    7.14
    sgu 128
    (zhuan)
  • 原文地址:https://www.cnblogs.com/WorldEye/p/14066782.html
Copyright © 2011-2022 走看看