我对 PrimeNg 还有另一个问题。单击按钮后我需要关闭边框。我尝试了很多方法:
host: {
::ng-deep .ui-button-icon-only{
border: none!important;
background-color: transparent!important;
outline: none!important;
}
}
Run Code Online (Sandbox Code Playgroud)
:focus即使我添加, 相同到.ng-star-inserted和,它也不起作用ng-star-inserted:focus
*:focus {
outline: none!important;
border: 0!important;
}
Run Code Online (Sandbox Code Playgroud)
该代码片段也不起作用,创建一个名为 nofocus 的新 scss 类并将其添加到按钮给我们带来零效果。我有:

我说的是点击后的边框。
我的标题中出现了我一生中的第一次错误:未处理的承诺拒绝:错误:收到消息的错误响应。我不知道是什么导致了这个错误,但幸运的是我的应用程序中当前只有一个 api 调用。我打算添加一些 catch 或promise.all,但我不知道在哪里以及每次尝试都失败了。有我的代码:
组件.ts:
async ngOnInit(): Promise<void> {
await this.attractionService.getAttractions().then((results) => {
results.forEach((attraction: { id: number; name: string; description: string; type: string; distance: string | undefined; imagePath: string | undefined; }) => {
this.section2ndModelAttractions.push(
new Card(
attraction.id,
attraction.name,
attraction.description,
attraction.type,
attraction.distance,
attraction.imagePath
)
)
})
})
}
Run Code Online (Sandbox Code Playgroud)
还有我的景点服务:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { firstValueFrom } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class AttractionService {
constructor(private http: HttpClient) { …Run Code Online (Sandbox Code Playgroud) 我不想检查用户是否未登录我的应用程序。如果发生这种情况,我不想将他重定向到 notLoggedView 或 verifyAccuontView。
此时代码如下所示,如果用户未创建,我无法进入 notLoggedView。
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true);
let user = Auth.auth().currentUser;
if (user == nil) {
self.performSegue(withIdentifier: "notLoggedView", sender: self);
}
}
Run Code Online (Sandbox Code Playgroud)
此代码的工作方式与上面相同(如用户存在,但 firebase 帐户为空)
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true);
if let user = Auth.auth().currentUser {
// action when account exist
} else {
self.performSegue(withIdentifier: "notLoggedView", sender: self);
}
}
Run Code Online (Sandbox Code Playgroud)