[Vue] Props Validations
Vue Props
2023-09-14 08:59:17 时间
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 } } } })
相关文章
- Java项目毕业设计:基于springboot+vue的电影视频网站系统「建议收藏」
- 尚硅谷Vue课程P30-P35笔记(后台回复 vue 可获得更多笔记!)
- VUE响应式原理-Dep类「建议收藏」
- 【Vue Conf 2021】现场参加 Vue Conf 2021 是怎样的一种体验(上)
- html使用vue axios,使用 Vue和axios
- 从零到一手写迷你版Vue
- VUE组件封装_vue组件内部双向绑定
- Vue分页导航_vue分页组件
- vuetify富文本编辑器_vue富文本编辑器的使用
- 开心档之Vue教程1
- 今天讲vue讲解专栏里的VUE组件
- Vue使用ECharts做图表
- Vue之路由(Router)
- 2023前端二面vue面试题_2023-02-23
- Vue接入Redis拓展应用的可能性(vue调redis)
- Vue结合Redis,加快数据读取速度(vue读取redis)
- Vue操作Redis掌握前端数据管理利器(vue操作redis)
- Vue结合Redis实现性能优化(vue引入redis)
- 使用Vue从Redis获取数据(vue去redis取数据)
- Oracle与Vue官网联合宣传前瞻技术,轻松开发(oracle vue官网)