1、自适应浏览器(监听浏览器宽高、如果有变化就存在localStorage里面去,或者有变化就通知其他组件改变化)
watch: {
// 如果发生改变,这个函数就会运行
height() {
this.changeFixed(this.width, this.height)
// eventBus.$emit('onresize', {'height': this.height }) 或者通知其他组件变化
}
},
methods: {
changeFixed(width, height) { // 动态修改样式
localStorage.setItem('Layout', JSON.stringify({'height': height }))
}
}
2、监控路由对象
watch: {
'$route': function(newroute, oldroute) {
console.log(newroute, oldroute);
// 可以在这个函数中获取到当前的路由规则字符串是什么
// 那么就可以针对一些特定的页面做一些特定的处理
}
1、作为过滤器:展开更多
computed:{
addressListFilter(){
return this.addressList.slice(0,this.limit);
}
}
2、作为过滤器:tab切换
computed: {
taskListfilter() {
switch (this.type) {
case 0: return this.taskList
case 1: return this.taskList.filter(item => item.type === '实时单')
case 2: return this.taskList.filter(item => item.type === '竞价单')
// default :return this.taskList
}
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。