我收到了一些奇怪的错误“这是空的”。我不知道是什么问题。这是我的演示Stackblitz.com和示例代码作为您的参考。
成分
ngOnInit() {
this.getCurrentLocation();
}
getCurrentLocation() {
navigator.geolocation.getCurrentPosition(position =>{
this.lat = position.coords.latitude;
this.lng = position.coords.longitude;
this.weatherInfo(this.lat, this.lng)
},function(){
this.origin = { lat: '3.140853', lng: '2.693207'};
console.log(this.origin)
this.weatherInfo(this.origin.lat, this.origin.lng)
})
}
weatherInfo(lat, lng){
console.log(lat, lng);
}
Run Code Online (Sandbox Code Playgroud) 我无法获得活动路由参数。当我控制台日志时,我得到了这个
. 此演示代码stackblitz
代码
constructor(private route: ActivatedRoute) {
this.route.params.subscribe((v) => {
// this.params = v;
console.log(v);
})
}
}
Run Code Online (Sandbox Code Playgroud)
路由模块
const routes: Routes = [
{
path: '',
component: PageComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
Run Code Online (Sandbox Code Playgroud) 我想在每个箭头之间创建空间,如下图所示,但它不起作用。我尝试添加padding,margin但它仍然无法正常工作。我想在每个箭头之间创建空间,如下图所示,但它不起作用。我尝试添加padding,margin但它仍然无法正常工作。
我提供此代码作为您的参考
html
<div class="container my-2">
<div class="row">
<div class="col-md-12 col-lg-12 mx-auto justify-content-center align-middle">
<ul id="breadcrumb">
<li><a href="#"> Option 1</a></li>
<li><a href="#">Option 2 </a></li>
<li><a href="#">Option 3 </a></li>
<li><a href="#"> Option 4</a></li>
<li><a href="#">Option 5 </a></li>
<li><a href="#"> Option 6</a></li>
</ul>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
#breadcrumb li:last-child a:after {
border: none;
}
#breadcrumb li a:before, #breadcrumb li a:after {
content: "";
position: absolute;
top: 0;
border: 0 solid #3498db;
border-width: 20px 10px; …Run Code Online (Sandbox Code Playgroud) 我想使用服务在组件之间共享数据。但它没有按预期工作。
成分
let myNum = 1;
sendChanges(myNum) {
this.breadService.sendData$.next(myNum);
}
Run Code Online (Sandbox Code Playgroud)
服务
public sendData$: Subject<any> = new Subject();
public setValue$: BehaviorSubject<any> = new BehaviorSubject(this.data);
Run Code Online (Sandbox Code Playgroud)
兄弟组件
ngOnInit() {
this.breadService.sendData$.subscribe(() => {
this.breadService.setValue$.subscribe(data=>{
this.id = data
console.log(this.id);
});
});
}
Run Code Online (Sandbox Code Playgroud)