这篇文章主要围绕CSS:它比“ulli”更快地呈现“ul>li”吗?展开,旨在为您提供一份详细的参考资料。我们将全面介绍CSS:它比“ulli”更快地呈现“ul>li”吗?,同时也会为您带来标签问题_
这篇文章主要围绕CSS:它比“ul li”更快地呈现“ul> li”吗?展开,旨在为您提供一份详细的参考资料。我们将全面介绍CSS:它比“ul li”更快地呈现“ul> li”吗?,同时也会为您带来标签问题_html/css_WEB-ITnose、Angular 11 - 无法绑定到“ngForOf”,因为它不是“li”的已知属性、Angular2 CLI错误“@ angular / compiler-cli”包未正确安装、Angular4中 “@angular/compiler-cli” 报错的解决方案的实用方法。
- CSS:它比“ul li”更快地呈现“ul> li”吗?
- Angular 11 - 无法绑定到“ngForOf”,因为它不是“li”的已知属性
- Angular2 CLI错误“@ angular / compiler-cli”包未正确安装
- Angular4中 “@angular/compiler-cli” 报错的解决方案
CSS:它比“ul li”更快地呈现“ul> li”吗?
使用“>”我从少数人那里听到的,而不是“”让渲染得更快?
.slide:hover > div > span {
border-color: #c8c8c8;
}
要么
.slide:hover div span {
border-color: #c8c8c8;
}
非常感谢!
更新:问题
任何可靠性问题?
这种差异充其量是微不足道的.考虑到这些事情,没有人应该浪费时间,精力或智力.这不是一个有用的优化.不要陷入过早优化的陷阱,尤其是对于像HTML / CSS这样的动态语言.
在担心其他任何事情之前,先编写清晰,可维护且功能齐全的代码.
如果ul> li看起来比ul li更清楚,然后就这样写.如果没有,不要.把事情简单化.
标签问题_html/css_WEB-ITnose
如题,我想用
就是比如这样
当我选中的是张三时后台获取的是001这个值,选中李四时获取的是002这个值,选中王五时获取的是003这个值,
请问要怎么实现
用select写的话我知道,就是
但是用
- 不知道怎么写
回复讨论(解决方案)
<ul> <li name="001">张三</li> <li name="002">李四</li> <li name="003">王五</li></ul> 登录后复制
$(function(){
$("ul li").click(function(){
var ar = $(this).attr("name");
alert(ar);
})
})
你自己包含一个jquery就可以了纯手打,有点错误,下面没打,你可以测试一下
如果是表单提交的话,你完全可以在表单中设置一个隐藏域,点击li时,改变隐藏域的值即可,最终提交表单即可
你点击ul的时候 改变 select 的 value
恩 好的 谢谢您
如果是表单提交的话,你完全可以在表单中设置一个隐藏域,点击li时,改变隐藏域的值即可,最终提交表单即可
恩,我现在是这样写的,但是还有一个获取到的值得问题,比如说:
点张三我应该获取的是001,但实际获取的是1,自动去掉了00
点李四我获取的是222,正常
点王五我获取的是0
点赵六获取的也是0
这个有什么办法解决吗?
function getDriverId(obj) { document.getElementById("driverId").value = obj.value; alert(document.getElementById("driverId").value);} 登录后复制
<input type="hidden" id="driverId" name="driverId" value="" /><ul> <li value="001" onclick=''getDriverId(this)''>张三</li> <li value="222" onclick=''getDriverId(this)''>李四</li> <li value="12345678910" onclick=''getDriverId(this)''>王五</li> <li value="测试" onclick=''getDriverId(this)''>赵六</li> </ul> 登录后复制问题已经解决了 ,谢谢各位,解决代码如下:
<div> <input type="hidden" id="driverId" name="driverId" value="" /> <input type="text" placeholder="" readonly> <ul> <li data-value="001">张三</li> <li data-value="111111">李四</li> <li data-value="12345678910">哈哈</li> <li data-value="你好">哇哈哈</li> </ul></div> 登录后复制
$(document).ready(function() { ''use strict''; var $driver = $(''.driver''), $list = $driver.children(''ul''); $list.delegate(''li'', ''click'', function() { var $this = $(this); $driver.value = $this.attr(''data-value''); //alert($driver.value); //alert($this.attr(''data-value'')); });}); 登录后复制
Angular 11 - 无法绑定到“ngForOf”,因为它不是“li”的已知属性
如何解决Angular 11 - 无法绑定到“ngForOf”,因为它不是“li”的已知属性?
我有一个 angular 11 应用,在默认应用模块内有一个名为 admin-layout
的模块。
这是我的app.module.ts
:
import { browserAnimationsModule } from "@angular/platform-browser/animations";
import { NgModule } from ''@angular/core'';
import { browserModule } from ''@angular/platform-browser'';
import { HttpClientModule } from ''@angular/common/http'';
import { RouterModule } from ''@angular/router'';
import { ToastrModule } from "ngx-toastr";
import { SidebarModule } from ''./sidebar/sidebar.module'';
import { FooterModule } from ''./shared/footer/footer.module'';
import { NavbarModule} from ''./shared/navbar/navbar.module'';
import { AppComponent } from ''./app.component'';
import { AppRoutes } from ''./app.routing'';
import { AdminLayoutComponent } from ''./layouts/admin-layout/admin-layout.component'';
@NgModule({
declarations: [
AppComponent,AdminLayoutComponent
],imports: [
browserAnimationsModule,RouterModule.forRoot(AppRoutes,{
useHash: true
}),SidebarModule,NavbarModule,ToastrModule.forRoot(),FooterModule,browserModule,HttpClientModule,],providers: [],bootstrap: [AppComponent]
})
export class AppModule { }
在 app/layouts/admin-layouts
中,我将 admin-layout.module.ts
设为:
import { NgModule } from ''@angular/core'';
import { RouterModule } from ''@angular/router'';
import { CommonModule } from ''@angular/common'';
import { FormsModule } from ''@angular/forms'';
import { AdminLayoutRoutes } from ''./admin-layout.routing'';
import { DashboardComponent } from ''../../pages/dashboard/dashboard.component''
import { NgbModule } from ''@ng-bootstrap/ng-bootstrap'';
import { HttpClientModule } from ''@angular/common/http'';
import { AngularsvgIconModule } from ''angular-svg-icon'';
@NgModule({
imports: [
CommonModule,RouterModule.forChild(AdminLayoutRoutes),FormsModule,NgbModule,AngularsvgIconModule.forRoot(),declarations: [
DashboardComponent,]
})
export class AdminLayoutModule {}
现在在组件 app/pages/dashboard/dashboard-components.ts
中,我有:
import { Component,OnInit,Input } from ''@angular/core'';
import { HttpClient,HttpHeaders } from ''@angular/common/http'';
import { environment } from ''./../../../environments/environment'';
import Chart from ''chart.js'';
import { NgbActiveModal,NgbModal } from ''@ng-bootstrap/ng-bootstrap'';
@Component({
selector: ''ngbd-modal-content'',template: `
<div>
<h4>Details</h4>
<button type="button"aria-label="Close" (click)="activeModal.dismiss(''Cross click'')">
<span aria-hidden="true">×</span>
</button>
</div>
<div>
<div>
<div>
<div>
<div>
<li *ngFor="let item of data; let i = index">
{{i}} {{item}}
</li>
</div>
</div>
</div>
</div>
</div>
`
})
export class NgbdModalContent {
@input() data: [];
constructor(public activeModal: NgbActiveModal) {}
}
@Component({
selector: ''dashboard-cmp'',moduleId: module.id,templateUrl: ''dashboard.component.html''
})
export class DashboardComponent implements OnInit{
public data = [];
httpOptions = { headers: new HttpHeaders({ ''Content-Type'': ''application/json'' }) };
constructor(private modalService: NgbModal,private http: HttpClient) {}
ngOnInit(){
const modalRef = this.modalService.open(NgbdModalContent,{ size: ''xl'' });
this.http.get<any>(environment.api_url + ''stats'').subscribe(data => {
for(var i = 1; i <= Object.keys(data["pole"]).length; i++){
data.push(data["data"][i]);
}
console.log(data);
modalRef.componentInstance.data = data;
})
}
}
我收到以下错误 - Can''t bind to ''ngForOf'' since it isn''t a kNown property of ''li''
console.log(data)
产生我 (2) [3.81,1.44]
我在这里做错了什么?与其他 stackoverflow 答案一样,他们需要我在模块中导入 CommonsModule
。我在应用程序级别和模块级别都有它。尝试从另一个删除也不起作用。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
Angular2 CLI错误“@ angular / compiler-cli”包未正确安装
npm install --save-dev @angular/cli@latest npm install
问题是运行ng服务时收到错误
The "@angular/compiler-cli" package was not properly installed. Error: The "@angular/compiler-cli" package was not properly installed. at Object.<anonymous> (/myng2project/node_modules/@ngtools/webpack/src/index.js:14:11) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (/myng2project/node_modules/@angular/cli/tasks/eject.js:10:19) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19)
"@angular/cli": "1.0.0-rc.4"
尝试安装较旧的
"@angular/cli": "1.0.0-rc.2"
Angular4中 “@angular/compiler-cli” 报错的解决方案
本人初学Angular,跟着官网教程时通过ng new my-app创建项目后,在ng serve --open时,会报如下错误:
The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler'
The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler' Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler' at Object.<anonymous> (D:\nodejs\node_modules\@angular\cli\node_modules\_@ngtools_webpack@1.7.4@@ngtools\webpack\src\index.js:14:11) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at Object.<anonymous> (D:\nodejs\node_modules\@angular\cli\tasks\eject.js:10:19) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19)
在其它地方搜索了多种解决方案,但不理想。而后在stackoverflow看到的一个可能是外国朋友的帖子:
https://stackoverflow.com/que...
就说很可能是angular没有正确安装,然后结合再看了Angular CLI 的github:
https://github.com/angular/an...
果然把这个困扰我大半天的烦人问题给解决了,现分享解决方案如下:
1.安装好node和npm,这个自不必多说,我这里指定了npm为淘宝的cnpm,原因你懂的,网速问题......
2.如果你的Angular CLI 是1.0.0-beta.28或者更早的版本,必须卸载没商量,命令如下:
cnpm uninstall -g angular-cli cnpm uninstall --save-dev angular-cli
3.你必须把全局和本地项目的Angular CLI更新到一个新版本:
在全局端:
cnpm uninstall -g @angular/cli cnpm cache clean *(或者:cnpm cache verify ,当npm版本>5时)* cnpm install -g @angular/cli@latest
在你的本地项目端:
rm -rf node_modules dist * rmdir /S/Q node_modules dist (在Windows 命令行下)* * rm -r -fo node_modules,dist (在Windows PowerShell下)* cnpm install --save-dev @angular/cli@latest cnpm install
4.此时进入项目目录,输入命令
ng serve --open
应该就没问题了。
呼。。。。。。就是这样的报错,搞的我弄了大半天,现在终于可以再次愉快地撸代码了。。。
PS:另外,为保险起见,我多安装了两个东西
cnpm install -g @angular/compiler-cli cnpm install webpack -g
这是在问题没解决前出现的缺少这两个插件的情况,补上。
关于CSS:它比“ul li”更快地呈现“ul> li”吗?的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于标签问题_html/css_WEB-ITnose、Angular 11 - 无法绑定到“ngForOf”,因为它不是“li”的已知属性、Angular2 CLI错误“@ angular / compiler-cli”包未正确安装、Angular4中 “@angular/compiler-cli” 报错的解决方案的相关知识,请在本站寻找。
本文标签: