[英]how do i call class in scss in type script or (.ts)
I have created class in scss and i want to call it inside my type script or (ts)我在 scss 中创建了 class 并且我想在我的类型脚本或(ts)中调用它
User Story: As a teacher, I want to see a student become disabled (Low opacity and unclickable) so that I know who are failed in my subject.用户故事:作为一名教师,我希望看到一名学生残疾(不透明且无法点击),以便我知道谁在我的科目中不及格。
.student{
opacity: 0px;
cursor: not-allowed;
background: #ccc;
}
ts ts
???
how i call scss class to my ts?我如何将 scss class 称为我的 ts?
html html
<container>
<div class="student">
<div class="move-center flex-align-center">
<p class="cont-body">Student name</p>
</div>
</div>
</container>
What exactly do you mean with "calling". “打电话”到底是什么意思。 You can't execute a css (or scss in your case) class, because it describes how something should look and does not describe behavior.
您不能执行 css(或您的情况下的 scss)class,因为它描述了某些东西的外观而不描述行为。
What you can do is assigning a scss class to an HTML-Element in TypeScript.您可以做的是将 scss class 分配给 TypeScript 中的 HTML 元素。
document.querySelector("css-selector").classList.add("student")
This will select first element (use querySelectorAll to select all elements) with the given css-selector.这将 select 第一个元素(使用 querySelectorAll 到 select 所有元素)与给定的 css-selector。 Then you add the css class to your classList attribute on the HTMl-Element you get from document.querySelector.
然后将 css class 添加到从 document.querySelector 获得的 HTMl-Element 的 classList 属性中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.