以上就是给各位分享''eval''isnullornotanobject,同时本文还将给你拓展''list''objectisnotcallable的问题、angular–无法解析Authentica
以上就是给各位分享''eval'' is null or not an object,同时本文还将给你拓展''list'' object is not callable的问题、angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、c# – “null如果object为null,则为null;如果object不为null,则为object.member”、collection element of type ''CGColorRef _Nullable'' (aka''stuct CGColor*'')is not an Objective-C object等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- ''eval'' is null or not an object
- ''list'' object is not callable的问题
- angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])
- c# – “null如果object为null,则为null;如果object不为null,则为object.member”
- collection element of type ''CGColorRef _Nullable'' (aka''stuct CGColor*'')is not an Objective-C object
''eval'' is null or not an object
The fix here: https://github.com/duncansmart/less.js-windows/issues/12 worked for me.
in mixins.less, I changed this:
// IE7 inline-block
// ----------------
.ie7-inline-block() {
*display: inline; /* IE7 inline-block hack */
*zoom: 1;
}
to this
// IE7 inline-block
// ----------------
.ie7-inline-block() {
*display: inline; /* IE7 inline-block hack */
*zoom: 1;
stop: being-broken;
}
''list'' object is not callable的问题
今天在练习写接口自动化的时候,报了一个''list'' object is not callable的错误,截图如下:
在网上找了一下原因,都说是有个参数命名为list,然后到导致无法调用token方法,但是我找了好久,发现我的代码中并没有参数名为list,截图如下:
后面的时候我自己打印了一下 APPLogin.token(),发现这里的值是一个列表,单独运行可以得到的值是 F[''f4edf7117632f0ca520635ac6aad66f5'']
发现值是可以的,但是合起来调用就一直调用不到那个方法,想到命名的问题,于是我就改了一下我的方法名
点击保存,然后重新运行就OK了,
产生问题的原因:一个方法中的方法名和变量名相同时,系统很容易无法识别到调用哪个
解决方法:将方法名或者变量名改变成不相同的(总的还是命名的规范问题)
angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])
Can’t resolve all parameters for AuthenticationService: ([object Object],?,[object Object])
我已经检查了几乎每个主题,并尝试了多种方法来解决它,但仍然无法在第二天击败它.
我试图像这样在appService中注入第一个authService但是得到了同样的错误
@Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService
我检查了所有DI和服务内部的导入顺序,在我看来一切都是正确的
如果有人可以帮我处理它,我很感激.
Angular 4.0.0
AuthService
import { Injectable } from '@angular/core'; import {Http,Headers,Response} from '@angular/http'; import 'rxjs/add/operator/toPromise'; import {Observable} from 'rxjs/Rx'; import {AppServices} from "../../app.services"; import {Router} from "@angular/router"; @Injectable() export class AuthenticationService { public token: any; constructor( private http: Http,private appService: AppServices,private router: Router ) { this.token = localStorage.getItem('token'); } login(username: string,password: string): Observable<boolean> { let headers = new Headers(); let body = null; headers.append("Authorization",("Basic " + btoa(username + ':' + password))); return this.http.post(this.appService.api + '/login',body,{headers: headers}) .map((response: Response) => { let token = response.json() && response.json().token; if (token) { this.token = token; localStorage.setItem('Conform_token',token); return true; } else { return false; } }); } logout(): void { this.token = null; localStorage.removeItem('Conform_token'); this.router.navigate(['/login']); } }
应用服务
import {Injectable} from '@angular/core'; import {Headers,Http,RequestOptions} from '@angular/http'; import {Router} from "@angular/router"; import {AuthenticationService} from "./auth/auth.service"; import 'rxjs/add/operator/toPromise'; import {Observable} from 'rxjs/Rx'; @Injectable() export class AppServices { api = '//endpoint/'; public options: any; constructor( private http: Http,private router: Router,public authService: AuthenticationService // doesn't work // @Inject(forwardRef(() => AuthenticationService)) public authService: AuthenticationService // doesn't work either ) { let head = new Headers({ 'Authorization': 'Bearer ' + this.authService.token,"Content-Type": "application/json; charset=utf8" }); this.options = new RequestOptions({headers: head}); } // ==================== // data services // ==================== getData(): Promise<any> { return this.http .get(this.api + "/data",this.options) .toPromise() .then(response => response.json() as Array<Object>) .catch((err)=>{this.handleError(err);}) }
应用模块
import { browserModule } from '@angular/platform-browser'; import { browserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import {BaseRequestOptions,HttpModule} from '@angular/http'; import { MaterialModule} from '@angular/material'; import {FlexLayoutModule} from "@angular/flex-layout"; import 'hammerjs'; import { routing,appRoutingProviders } from './app.routing'; import { AppServices } from './app.services'; import {AuthGuard} from "./auth/auth.guard"; import {AuthenticationService} from "./auth/auth.service"; import {AppComponent} from './app.component'; import {AuthComponent} from './auth/auth.component'; import {NotFoundComponent} from './404/not-found.component'; import { HomeComponent } from './home/home.component'; @NgModule({ declarations: [ AppComponent,AuthComponent,NotFoundComponent,HomeComponent ],imports: [ browserModule,browserAnimationsModule,FormsModule,HttpModule,routing,MaterialModule,FlexLayoutModule ],providers: [AppServices,AuthGuard,AuthenticationService],bootstrap: [AppComponent] }) export class AppModule { }
解决方法
你可以使用
export class AuthenticationService { public token: any; appService: AppServices; constructor( private http: Http,// private appService: AppServices,injector:Injector; private router: Router ) { setTimeout(() => this.appService = injector.get(AppServices)); this.token = localStorage.getItem('token'); }
另见DI with cyclic dependency with custom HTTP and ConfigService
要避免使用setTimeout,您还可以从AppService的构造函数中设置AuthenticationService.appService(或者相反)
c# – “null如果object为null,则为null;如果object不为null,则为object.member”
> How to check for nulls in a deep lambda expression? 10个
我正在尝试编写一个通用扩展方法,让我这样做:
this.startDate = startDateXAttribute.NullOrPropertyOf<DateTime>(() => { return DateTime.Parse(startDateXAttribute.Value); });
如果NullOrPropertyOf()在null对象上使用(例如,如果startDateXAttribute为null),则返回null,如果它不为null,则返回Func的结果.
这种扩展方法会是什么样的?
解决方法
x = foo.?bar.?baz;
也就是说,如果foo或foo.bar为null,则x为null,如果它们都不为null,则为foo.bar.baz的结果.
我们认为它适用于C#4,但它没有使它在优先级列表的顶部附近.对于该语言的假设未来版本,我们会记住这一点.
更新:C#6将具有此功能.有关设计注意事项的讨论,请参见http://roslyn.codeplex.com/discussions/540883.
collection element of type ''CGColorRef _Nullable'' (aka''stuct CGColor*'')is not an Objective-C object
类型转换为ID解决问题: “Collection element of type ''CGColorRef'' (aka ''struct CGColor *'') is not an Objective-C object”
编译器理解Objective-C方法返回的核心基础类型遵循历史可命名约定(见-高级内存管理编程指南)。例如,编译器知道,在iOS的cgcolor返回用UIColor的cgcolor方法不拥有。您必须仍然使用一个合适的类型转换,
1down voteaccepted |
It is documented in the "Transitioning to ARC Release Notes":
|
参考:http://stackoverflow.com/questions/21933209/why-type-cast-to-id-will-get-rid-of-this-error-message-collection-element-of-ty
今天关于''eval'' is null or not an object的讲解已经结束,谢谢您的阅读,如果想了解更多关于''list'' object is not callable的问题、angular – 无法解析AuthenticationService的所有参数:([object Object],?,[object Object])、c# – “null如果object为null,则为null;如果object不为null,则为object.member”、collection element of type ''CGColorRef _Nullable'' (aka''stuct CGColor*'')is not an Objective-C object的相关知识,请在本站搜索。
本文标签: