特殊日期 App页面置灰设置

特殊日期 App页面置灰设置

开始写这个需求的时候需求不是很明确,产品说要整个App页面都置灰
思路:后台管理端有个置灰按钮,打开后传给前端一个状态 true、false或者0、1都可以,
传给前端后前端根据这个状态判断,设置 filter: grayscale(100%);
app.vue中:

<div id="app" :style="setStyles == '0' ? 'filter: grayscale(100%);' : ''" >
	...
</div>

发现这样设置后有的 position: fixed会失效
把 filter: grayscale(100%);设置在html上就ok了
后面上测试g产品又说只要首页置灰,其他页面不变,emm…

data() {
    return {
      setStyles: "1",  //0 开  1关
      routerPath: ""
    }
},
watch: {
	 '$route' (to, from){
	   // console.log('当前页面路由:' + to.path);
	   // console.log('上一个路由:' + from.path);
	   //获取是否置灰
	   this.getSetStyle()
	   if(to.path == '/home/index') {
	     this.routerPath = "/home/index"
	   }else {
	     this.routerPath = ""
	   }
	 },
},

methods:{
    //设置置灰
    getSetStyle() {
      setStyle(this.pageVo).then(res => {
        if(res.data.code == 200) {
          this.setStyles = res.data.obj.status.toString();
          if(res.data.obj.status == 0 && this.routerPath == '/home/index') {
            let html_box = document.getElementById("html-box")
            html_box.style.filter = "grayscale(100%)"
          }else {
            let html_box = document.getElementById("html-box")
            html_box.style.filter = "grayscale(0)"
          }
        }else {
          this.$toast.fail(res.data.msg)
        }
      })
    },
}

在这里插入图片描述

![在这里插入图片描述](https://img-blog.csdnimg.cn/15416aa73101486291ded0b217a7aeec.png#pic_center
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值