GVKun编程网logo

css – 我的Ng-Class无法正常工作

15

对于css–我的Ng-Class无法正常工作感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于.toggleClass()函数在快速点击时无法正常工作、Angular2语义UI下拉JS无法正

对于css – 我的Ng-Class无法正常工作感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于.toggleClass() 函数在快速点击时无法正常工作、Angular 2语义UI下拉JS无法正常工作、angular度路由,刷新给404,.htaccess无法正常工作、CSS max-width无法正常工作的宝贵知识。

本文目录一览:

css – 我的Ng-Class无法正常工作

css – 我的Ng-Class无法正常工作

我已经内置了Btn风格,所以我只想将它自定义为新风格

<style>
    .btn.activeother {
        color: #fff;
        background-color:Red;
    }
</style>

并希望像这样使用它

<div>
       <label  ng-repeat="list in inputarray"  name="{{assessmenttype}}" 
       ng-model="$parent.selecteditem"  ng-https://www.jb51.cc/tag/score/" target="_blank">score && selecteditem!= normalscore }"  btn-radio="{{list.score}}">{{list.name}}</label>
       </div>

所以在这里我将传递normalscore为2并且我有3个项目,每个项目包含列表得分为1,2,3,列表名称为a,b,c

所以我想要使用ng-class设置我的服装css类.btn.activeother
使用逻辑,如果选择项目分数与正常相同,我想要.btn.activeother应用而不是默认btn有效

所以请帮我解决这个问题
目前我的ng-class没有处理这个请告诉我什么是正确的?

解决方法

初始定义类.btn和条件检查仅.activeother类

<div>
       <label  ng-repeat="list in inputarray"  name="{{assessmenttype}}" 
       ng-model="$parent.selecteditem"ng-https://www.jb51.cc/tag/score/" target="_blank">score && selecteditem != normalscore }"  btn-radio="{{list.score}}">{{list.name}}</label>
       </div>

.toggleClass() 函数在快速点击时无法正常工作

.toggleClass() 函数在快速点击时无法正常工作

如何解决.toggleClass() 函数在快速点击时无法正常工作?

enter image description here

$(document).on("click",".collapse-icon",async(event) => { //TreeView Collapse Control
  let collapse_icon = await $(event.target).closest("span").siblings(".collapse");
  await $(collapse_icon).collapse("toggle");
  await $(event.target).toggleClass(''fa-plus-circle fa-minus-circle'');
});
<!DOCTYPE html>
<html lang="en">

<head>
  <Meta charset="UTF-8">
  <Meta http-equiv="X-UA-Compatible" content="IE=edge">
  <Meta name="viewport" content="width=device-width,initial-scale=1.0">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
</head>

<body>
  <li>
    <span>
            <i></i>
        </span>
    <span>Permissions</span>
    <ol>
      <li>read</li>
      <li>edit</li>
      <li>delete</li>
      <li>update</li>
    </ol>
  </li>
</body>

</html>

如果我非常快速地多次单击加号图标,流程会中断并开始相反的工作。当它必须显示减号图标时,它开始显示加号图标,反之亦然。我做错了什么,我该怎么做解决了吗?

解决方法

它无法正常工作,因为 .collapse-icon 的类切换不等待可折叠项目完成呈现。

使其正常工作的一种方法是在决定 show 元素的类名时考虑可折叠项目的 collapse-icon 类名。

$(document).on("click",".collapse-icon",(event) => { //TreeView Collapse Control
  const $target = $(event.target);
  const $collapsable = $target.closest(''span'').siblings(''.collapse'');
  const isShown = $collapsable.hasClass(''show'');

  $collapsable.collapse(''toggle'');

  $target.toggleClass(''fa-plus-circle'',isShown);
  $target.toggleClass(''fa-minus-circle'',!isShown);
});
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
</head>

<body>
  <li>
    <span>
            <i></i>
        </span>
    <span>Permissions</span>
    <ol>
      <li>read</li>
      <li>edit</li>
      <li>delete</li>
      <li>update</li>
    </ol>
  </li>
</body>

</html>

Angular 2语义UI下拉JS无法正常工作

Angular 2语义UI下拉JS无法正常工作

我正在尝试使用语义UI在Angular 2中创建通用下拉控件.我有以下代码:

import {ElementRef,Component,OnInit,EventEmitter} from "angular2/core";
import {DropdownValue} from "./dropdown-value";

declare var jQuery: any;

@Component({
selector: 'my-dropdown',inputs: ['selectedItem','items','label'],outputs: ['selectedItemChange'],template: `
<div>        
  <label>{{label}}</label>        
    <select[ngModel]="selectedItem.value" (ngModelChange)="onChange($event)">
      <!--<option value="" selected>Please Select</option>-->
      <option *ngFor="#item of items" [value]="item.value">{{item.label}}</option>
    </select>        
</div>`
})

export class MyDropdownComponent implements OnInit {

items: DropdownValue[];
selectedItem: DropdownValue;
selectedItemChange: EventEmitter<any> = new EventEmitter();

constructor(private elementRef: ElementRef) {
}

ngOnInit(): any {
    this.items.unshift(new DropdownValue('','Please Select'));
    this.selectedItem = this.selectedItem || this.items[0];
    //jQuery(this.elementRef.nativeElement).find('select').dropdown();
}

onChange(newValue) {
    let selectedItem = this.items.find(item => item.value == newValue);
    this.selectedItemChange.emit(selectedItem);
}

}

这实际上工作得很好(没有Semantic UI JS样式),问题是,只要我取消注释//jQuery(this.elementRef.nativeElement)行.find(‘select’).dropdown(); “请选择”不再可见,并且不显示初始选择.

解决方法

正如Günter所说,你应该在ngAfterViewInit()中调用jQuery().dropdown().

dropdown()重置所选值.所以你必须在下拉()后重新选择所需的值:

ngAfterViewInit(){
  jQuery(this.elementRef.nativeElement).find('select').dropdown({allowTab:false});
  jQuery(this.elementRef.nativeElement).find('select').dropdown("set selected",this.selectedItem.value);
}

见plunkr

angular度路由,刷新给404,.htaccess无法正常工作

angular度路由,刷新给404,.htaccess无法正常工作

这已被问了很多次,但我似乎还没有弄清楚我的angular度应用程序是什么问题。

我的路由工作正常,直到我刷新页面,它给了我“页面未find”。 stream行的解决scheme是,我添加一个.htaccess文件到我的应用程序的根,但它仍然无法正常工作。 我甚至尝试了不同的.htaccess脚本。

''Access-Control-Allow-Origin''头部包含多个值 – Nginx + sails.js

Node.js命令提示符错误ENOENT,stat C: Users student AppData Roaming npm

用量angular器如何设置Internet Explorer的configuration?

net :: ERR_CONTENT_LENGTH_MISMATCH在Nginx 1.8.0上

Npm安装; 在angular-phonecat@0.0.0预启动脚本失败

试试这个.htaccess:

Options +FollowSymLinks <ifmodulee mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !index RewriteRule (.*) index.html [L] </ifmodulee>

总结

以上是小编为你收集整理的angular度路由,刷新给404,.htaccess无法正常工作全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

CSS max-width无法正常工作

CSS max-width无法正常工作

我有这个代码,但奇怪的是max-width和属性不起作用:

HTML:

<body>
    <img src="imgs/topBar.png">
    <div id ="wrapper">
    </div>
</body>

CSS:

body {
    padding: 0;
    margin: 0;
}
body img:first-child{
    width: 100%;
    height: 5px;
    margin:0;
    display: block;
}
#wrapper {
    width: 100%;
    max-width: 1200px;
    height: 100px;
    margin: 0 auto;
    border: 4px solid;
}

我做了一个http://jsfiddle.net/vkdbq/

解决方法

你可以设置:

#wrapper {
    -webkit-Box-sizing: border-Box; /* Safari,other WebKit */
    -moz-Box-sizing: border-Box;    /* Firefox,other Gecko */
    Box-sizing: border-Box;         /* Opera/IE 8+ */

    width: 100%;
    max-width: 1200px;
    height: 100px;
    margin: 0 auto;
    border: 4px solid;
}

今天关于css – 我的Ng-Class无法正常工作的讲解已经结束,谢谢您的阅读,如果想了解更多关于.toggleClass() 函数在快速点击时无法正常工作、Angular 2语义UI下拉JS无法正常工作、angular度路由,刷新给404,.htaccess无法正常工作、CSS max-width无法正常工作的相关知识,请在本站搜索。

本文标签:

上一篇相对于父级的CSS字体大小(相对于父级的css字体大小是多少)

下一篇css – AngularJS动画交换表格中的行(angularjs tab切换)