go version go1.15.2 darwin/amd64
Run Code Online (Sandbox Code Playgroud)
在我的文件夹中,我有两个文件:main.go和user.go以及其他文件go.mod,例如go.sum等。
当尝试从中导入包时,user.go我在导入中收到错误:
查询“最新”没有匹配的版本
go version go1.15.2 darwin/amd64
Run Code Online (Sandbox Code Playgroud)
package user
import (
"os"
"os/user"
"path/filepath"
)
Run Code Online (Sandbox Code Playgroud)
我尝试遵循一些建议,例如go clean -modcachegit hub 问题中的建议
我正在使用 gomods,所以我不想禁用它。谢谢
删除文件的文档说,据我所知,它应该与readfile一样导入。
我错过了什么吗?
在我的代码中我有:
import { readFile, rm } from 'fs/promises'
export async function foo () {
try {
const res = await readFile('./file.txt') // works
await rm('./file.txt') // TypeError: promises_1.rm is not a function
} catch(e) {
console.log('er', e)
}
}
Run Code Online (Sandbox Code Playgroud) tl; dr:向下滚动到解决方案
我有一个循环依赖项,并且正在收到警告,这是正确的,但是,我正在对其进行管理。问题是我有一个聊天组件。在角落,您可以选择查看他们的个人资料页面,而在他们的个人资料页面中,您可以选择向他们发送消息,因此是循环依赖性。我正在通过管理
public async openProfile(): Promise<void> {
this.modalCtrl.dismiss(); //closing the chat component before opening the profile modal
const profile = await this.modalCtrl.create({
component: ProfileComponent,
});
await profile.present();
}
Run Code Online (Sandbox Code Playgroud)
public async openChat(): Promise<void> {
this.modalCtrl.dismiss(); //closing the profile component before opening the chat modal
const chat = await this.modalCtrl.create({
component: ProfileComponent,
});
await chat.present();
}
Run Code Online (Sandbox Code Playgroud)
有没有更简单的方法来处理这种循环依赖关系?
更新:根据下面的建议,我尝试创建服务。但是现在我有了一个三向依赖圈:
private modalService: ModalService;
constructor(modalService: ModalService){
this.modalService = modalService
}
public async openProfile(): Promise<void> {
this.modalService.openProfile(this.userData);
}
Run Code Online (Sandbox Code Playgroud)
private modalService: ModalService; …Run Code Online (Sandbox Code Playgroud) 是的,所以我正在迭代一系列信息,并且这些信息按照我想要的方式显示,但是,我在控制台中收到了一些令人惊讶的错误:ERROR TypeError: "_v.context.$implicit is undefined"
API服务:
private extractData(res: Response) {
let body = res;
return body || {};
}
getWeather(city: string, isoCode: string): Observable<any> {
return this.http.get(`${this.endPoint}${city},${isoCode}${this.constants.apiKey}`)
.pipe(map(this.extractData));
}
Run Code Online (Sandbox Code Playgroud)
使用api服务的组件:
theWeather:any = [];
countryList = COUNTRIES;
isLoading: boolean = true;
showWeather: boolean = false;
constructor(private apiCall:ApiService) { }
ngOnInit() {
this.retrieveWeather()
};
retrieveWeather() {
console.log('COUNTRY LIST', this.countryList);
this.theWeather = [];
this.countryList.map((element, i) => {
this.apiCall.getWeather(element.city, element.countryIso)
.subscribe((data: {}) => {
element.weatherInfo = data;
});
this.isLoading = false;
});
this.showWeather …Run Code Online (Sandbox Code Playgroud) 好吧,这确实是一个我无法解决的简单问题。我有一个看起来像这样的html文件:
<ol>
<li> item 1 </li>
<li> item 2 </li>
<li> item 3 </li>
</ol>
Run Code Online (Sandbox Code Playgroud)
附带的CSS看起来像这样:
ol {
list-style: none;
counter-reset: li-counter;
}
ol li {
counter-increment: li-counter;
}
ol li::before {
content: counter(li-counter);
color: #59cbbe;
font-weight: bold;
width: 20px;
height: 20px;
border: 2px solid black;
border-radius: 50px;
padding: 4px;
margin: 10px;
}
Run Code Online (Sandbox Code Playgroud)
这是codepen
我曾尝试以下和修改这个例子,但没能得到它。所以我也尝试了这个。当您查看电笔时,我遇到的主要问题是圆圈不是圆圈,它们始终是我使用的椭圆形和椭圆形天气,30px或者50%缺少某些东西。抱歉,这是一个非常简单的答案,但是,我对CSS的了解不是那么好。