-
computed计算
- 从现有数据计算出新的数据(只读)
-
compued:{ "total":function(){ return xxxx } }
- watch监听
- 监听数据的变化执行回调函数
-
watch:{ "obj":{ handler(nval){ //执行回调函数 } deep:true, } }
-
- 监听数据的变化执行回调函数
- class
- 文本
:class="active"
没有加单引号的active是一个变量不是字符串
- 对象
:class="{active:flag}"
- 数组
:class:"list"
- 文本
- style
- :style="{color:'red',fontSize:''20px}"
- css属性驼峰式写法
-
js方法回顾
- 数组
- indexOf()
查找对应下标
- 删除
- shift 前删除
- pop 后删除
- splice 中间删除
- 添加
- unshift 前添
- push 后添
- splice 也可以添加
- 翻转
reverse
- 转字符串
join()
- 连接数组
concat()
- 高阶
- filter 过滤
- forEach 遍历
- map 映射
- reduce 累计
- some 有一个
- every 每一个
- find 查找符合条件元素
- findIndex 查找符合条件的元素下标
- sort 排序
- indexOf()
- 字符串
- 查询 字符串下标,找不到返回-1
indexOf
lastIndexOf
- split(“”) 分割为数组
- splice(start,end)切割字符串
- subString(start,end)截取字符串(按下标end)
- subStr(start,end)截取字符串(按长度len)
- 查询 字符串下标,找不到返回-1
- json
- eval()字符串当js执行
- JSON.parse(str)
json字符串转换为js对象
- JSON.stringify(obj)
把js对象转换为json字符串
- 本地存储
localStorage- getItem(key)
获取值
- setItem(key,value)
存储值
- removeItem(key)
删除存储
- clear()
清空
- getItem(key)
- 数组