zoukankan      html  css  js  c++  java
  • [Vue] Props Validations

    Components can specify requirements for its props, such as the types you’ve already seen. If a requirement isn’t met, Vue will warn you in the browser’s JavaScript console. This is especially useful when developing a component that’s intended to be used by others.

    Vue.component('my-component', {
      props: {
        // Basic type check (`null` matches any type)
        propA: Number,
        // Multiple possible types
        propB: [String, Number],
        // Required string
        propC: {
          type: String,
          required: true
        },
        // Number with a default value
        propD: {
          type: Number,
          default: 100
        },
        // Object with a default value
        propE: {
          type: Object,
          // Object or array defaults must be returned from
          // a factory function
          default: function () {
            return { message: 'hello' }
          }
        },
        // Custom validator function
        propF: {
          validator: function (value) {
            // The value must match one of these strings
            return ['success', 'warning', 'danger'].indexOf(value) !== -1
          }
        }
      }
    })

    Doc

  • 相关阅读:
    eclipse安装插件(具体过程省略)
    Linux权限
    Anaconda + python环境搭建
    Hadoop的shell命令
    安装Hadoop(单机)
    CentOS 7安装jdk
    Linux文档内容操作
    EOJ 3 玩具谜题
    [转载]基础算法——筛法求素数
    EOJ 3213 向右看齐
  • 原文地址:https://www.cnblogs.com/Answer1215/p/9428133.html
Copyright © 2011-2022 走看看