11.9-11.13
# 11.9-11.13汇总
## 1.表格宽高设置
table
height:最小值 内容超出自动延长
width:最大值
tr
width:无作用
height:与tr有关,若tr都设置height,各个tr的height按照比例分配总的height值;当tr都没有设置height,平分height值;有的设置有的没有设置,先保证各个tr的基本需求,剩下的再满足具体值tr,之后全部给没有具体值的tr
td
width:所处一列每个td都与width有关,取最大值为每个td的width,默认td根据世纪内容比例分配
height:td所在行的最大高度
td以及tr的height 哪个值大就用哪个
## 2.Prop
(1) prop 用来传递一个初始值
```js
props: ['initialCounter'],
data() {
return {
counter: this.initialCounter
}
}
```
(2)这个 prop 以一种原始的值传入且需要进行转换
```js
props: ['size'],
computed: {
normalizedSize: function () {
return this.size.trim().toLowerCase()
}
}
```
(3)Prop 验证
```js
app.component('my-component', {
props: {
// 基础的类型检查 (`null` 和 `undefined` 会通过任何类型验证)
propA: Number,
// 多个可能的类型
propB: [String, Number],
// 必填的字符串
propC: {
type: String,
required: true
},
// 带有默认值的数字
propD: {
type: Number,
default: 100
},
// 带有默认值的对象
propE: {
type: Object,
// 对象或数组默认值必须从一个工厂函数获取
default: function() {
return { message: 'hello' }
}
},
// 自定义验证函数
propF: {
validator: function(value) {
// 这个值必须匹配下列字符串中的一个
return ['success', 'warning', 'danger'].indexOf(value) !== -1
}
},
// 具有默认值的函数
propG: {
type: Function,
// 与对象或数组默认值不同,这不是一个工厂函数 —— 这是一个用作默认值的函数
default: function() {
return 'Default function'
}
}
}
})
```
## 3.验证手机号
```js
// 判断是否为手机号
isPoneAvailable(pone) {
var myreg = /^[1][0-9]{10}$/
if (!myreg.test(pone)) {
return false
} else {
return true
}
}
```
## 4.获取焦点、失去焦点
|语法|作用|
|-|-|
|onclick|点击事件|
|onmoveover|鼠标经过事件|
|onfocus|获取焦点|
|onblur|失去焦点|