Angular日历:在beforeWeekViewRender事件中添加的自定义css在resize事件中被删除。
创始人
2024-10-29 05:00:32
0

要在Angular日历的beforeWeekViewRender事件中添加自定义CSS,并避免在resize事件中被删除,可以使用以下解决方法:

  1. 在组件的构造函数中引入Renderer2模块,并注入到构造函数中:
import { Component, OnInit, Renderer2 } from '@angular/core';

constructor(private renderer: Renderer2) { }
  1. 在ngAfterViewInit生命周期钩子中添加事件监听器,并在事件处理程序中设置自定义CSS:
ngAfterViewInit() {
  this.renderer.listen('window', 'beforeunload', () => {
    // 添加自定义CSS
    const customCss = document.createElement('style');
    customCss.type = 'text/css';
    customCss.innerHTML = '.custom-class { background-color: yellow; }';
    document.head.appendChild(customCss);
  });
}
  1. 在resize事件中重新添加自定义CSS:
ngAfterViewInit() {
  this.renderer.listen('window', 'resize', () => {
    // 重新添加自定义CSS
    const customCss = document.createElement('style');
    customCss.type = 'text/css';
    customCss.innerHTML = '.custom-class { background-color: yellow; }';
    document.head.appendChild(customCss);
  });
}

通过这种方式,你可以确保在resize事件中重新添加自定义CSS样式,避免被删除。请根据实际需求进行调整,并将代码添加到你的组件中。

相关内容

热门资讯

三分钟了解!红龙poker辅助... 三分钟了解!红龙poker辅助工具,cloudpoker怎么开挂,本来真的是有挂(有挂实锤)亲,关键...
揭秘攻略!wepoker手机版... 揭秘攻略!wepoker手机版辅助,hh poker辅助有用吗,确实真的有挂(有挂头条)1、每一步都...
玩家爆料!wepoker辅助器... 玩家爆料!wepoker辅助器下载,wepoker透视辅助下载,好像真的是有挂(有挂方针)1、wep...
分辨真假!德普之星私人局透视,... 分辨真假!德普之星私人局透视,wepoker私人局辅助,一贯存在有挂(有挂分享)1、下载好透视辅助下...
推荐十款!wepoker到底有... 推荐十款!wepoker到底有没有透视,aapoker辅助软件合法吗,果然真的是有挂(有挂方法)1、...
盘点一款!购买的wpk辅助在哪... 盘点一款!购买的wpk辅助在哪里下载,wejoker辅助软件视频,本来真的是有挂(揭秘有挂)1)免费...
揭秘一下!we poker辅助... 揭秘一下!we poker辅助器,wepoker怎么发冤家牌,切实存在有挂(有挂技巧)1、每一步都需...
一分钟揭秘!wepoker数据... 一分钟揭秘!wepoker数据分析工具,wepoker怎么买辅助,竟然真的是有挂(有挂方略)透视方法...
研究成果!wepoker私人局... 研究成果!wepoker私人局俱乐部辅助,wepoker免费脚本弱密码,一贯真的有挂(有挂技巧)1、...
普及知识!aa poker辅助... 普及知识!aa poker辅助包,wepoker怎么看底牌,总是真的有挂(有挂细节)1、脚本辅助下载...