1.遍历对象
for(var k in list){
console.log(k+':'+list[k]);
}
2.Map 数组字符串转数字
['1','2','3'].map(function(item) {
return +item;
});
3.Map 把res里面的ChineseMedicines里面的key值是id的数据拿出来
放到 popArr数组中
that.editPop.popArr = res.ChineseMedicines.map(function (item) {
return +item.Id
})
//简写
that.Top5CS = res.Top5CS.map(x => x.UserName)
4.行内框元素之间的空白元素会根据font-size 变大
如果发现页面高度无法更改 在页面也查看不到 记得在行内元素加display:block;
5.通过find方法 查找id匹配的对象 取其中Name字段的数据
//Es6写法
this.citys.find(item => item.id === this.city)['name']
//通用写法 列子
that.pageTwo.type2 = that.pageTwo.type2List.find(function (item) {
return item.Name === data.type2
})['Id']
6.获取到索引 更改当前索引的数据
that.messageData.Inquiry[this.InquiryIndex] = arr
7.定时器
等待几秒之后做操作
setTimeout(function(){
window.location.href = '../caseHistory/caseHistoryList.html';
},1500);
8.Json数据传给后台 里面的对象需要进行再次 JSON.stringify()
var palpation = that.messageData.Palpation
that.messageData.Palpation = JSON.stringify(palpation)
9.媒体响应式
@media screen and (max-width: 970px) {
nav {
display: none;
}
.content-in {
margin-left: 0 !important;
}
}
- 传入时间 返回对应的秒 2019/10/03 格式
//传入时间 返回对应的秒
function transformSS(data){
return new Date(data.replace("/", ",")).getTime();
}
// 时间验证 传值(开始时间,结束时间)
function timeVerification(begin,edn,that){
if (begin == '' || edn == '') {
that.$Message.warning('请选择时间,不能为空');
return false
}
var flg = checkDate2(edn)
//判断选择的结束时间不可以大于当前时间
if (!flg) {
that.$Message.warning('结束时间不能大于当前时间!');
return false
}
var startTime = transformSS(begin);//开始时间
var endTime = transformSS(edn);//结束时间
//判断结束时间是否比开始时间大
if (startTime > endTime) {
that.$Message.warning('开始时间必须小于结束时间!');
return false
}
// if (this.useType=='hour'){
// var kaishi = transformSS(this.startDate)
// var jieshu = transformSS(this.endDate)
// if ((jieshu - kaishi) / 1000 > 604800) {
// this.$Message.warning('选择小时状态下,时间间距不可以大于7天');
// }
// }
// this.tabPage.Page = 1
return true
}
网友评论