this.$set 数组对象渲染
css计算属性
height: calc(~“100% - 50px”);
1、 普通去重
function unique(arr) {
return arr.filter((item, index)=> {
return arr.indexOf(item) === index
})
}
unique([1,2,3,3,4,4,4,5])
// [1, 2, 3, 4, 5]
2、根据数组中某个对象值去重
function unique(arr,key) {
const res = new Map();
return arr.filter((a) => !res.has(a[key]) && res.set(a[key], 1))
}
unique([
{
from:'张三',
to: '河南'
},
{
from:'王二',
to: '杭州'
},
{
from:'王二',
to: '河南'
},
{
from:'王二',
to: '山东'
},
],'from')
vue样式判断
<div class="orderinfo" :style="appointType === '0'?'':'height:100%'">
:style="!areaCode || !phoneNumber || !receivedCode || !verification ? '{backgruond:#ccc}' : $store.state.store.config.background"
三元表达式
:style="{disabled:!amendPhoneIsShow?'':'disabled'}"
三元表达式和class共存
<div :class="['bottom-wrap',{'wrap-expend': !expand}]">
:class="[{'active':navIndex==4},'nav4']"