• angular bug


    1.当我想通过.ts文件控制前台样式时:

    error TS2339: Property 'style' does not exist on type 'Element'.
    解决方案: 设定变量类型为any

    var dgbc:any =document.getElementsByClassName('div-bg');    
    dgbc[0].style.backgroundColor='#D8D8D8';   
    
    • 1
    • 2

    2.同一页面进行点击切换时,ngfor进行页面渲染,并且通过ts设定前台样式时,有的样式失效
    (1):打印dgbc的长度时,显示长度为上一阶
    在这里插入图片描述
    点送签,显示的是待签核页面的数据长度。

     <div class="div-out"  *ngFor="let item of items  let i=index">
        <div class="div-bg" id="{{i}}" (click)="isShow(i)" style="background-color: #D8D8D8;">
            <span class="title-nav">
              <div style="float:left">{{item}}</div>
              <div class="num">{{subSum[i]}}</div>
            </span>
        </div>
         <div [hidden]="flag!=i">
            <st #st [data]="firstData" [columns]="firstColumns"></st>
         </div>
      </div>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    解决方案:::监听ngfor:当ngfor执行完后再执行页面渲染

       setTimeout(() => {
            var dgbc:any =document.getElementsByClassName('div-bg');
            if(dgbc.length== this.subSum.length)
                  this.isShow(0);
                  return;
            }, 1);  
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    3.STComponent Property 'st' has no initializer and is not definitely assigned
    意思是STComponent属性’st’没有初始化器,也没有明确赋值
    解决方案:
    Just go to tsconfig.json and set

    "strictPropertyInitialization": false
    
    • 1

    to get rid of the compilation error. --以消除编译错误。

    Otherwise you need to initialize all your variables which is a little bit annoying–否则你需要初始化所有的变量这有点烦人

  • 相关阅读:
    40道JAVA经典算法面试题(答案)
    网络基础选择题
    C# —— 对象
    分布式事务(Seata) 四大模式详解
    2024年最新通信安全员考试题库
    【网络服务&数据库教程】08 邮件服务
    第9/100天 阅读笔记
    2022谷粒商城学习笔记(七)属性分组相关功能
    《持续交付:发布可靠软件的系统方法》- 读书笔记(十三)
    java118-vector类
  • 原文地址:https://blog.csdn.net/c_x_m/article/details/112256992