我一页叫:
List<string> result = list
.Select((value, index) => new {
value,
index
})
.GroupBy(item => item.value, StringComparer.OrdinalIgnoreCase)
.SelectMany(chunk => chunk
.Select((item, index) => new {
value = string.Format("{0}{1}", item.value, new string('_', index)),
index = item.index
}))
.OrderBy(item => item.index)
.Select(item => item.value)
.ToList();
使用此网址生成正确的导航事件:
cat
Cat_
kitty
kittY_
dog
cAt__
Dog_
monkey
monKey_
Monkey__
但在目标页面中,// call this to nav to '/list' with queryParams
const data = {'map-center': this.loc.join(',')};
this.router.navigate(['/list'], {queryParams:data} );
在两种情况下都为空:
http://localhost:8100/list?map-center=13.7414025,100.51102500000002
但是,当我从浏览器重新加载时,queryParam很好。发生了什么事?
[更新] ,如果我在网址中添加参数,则queryParam
可以正常工作。
// <ion-router-outlet main
// (activate)="!!$event.viewWillEnter ? $event.viewWillEnter() : undefined"
viewWillEnter(){
// using constructor(){ private route: ActivatedRoute }
const mapCenter = this.route.snapshot.queryParams['map-center'];
this.route.queryParams.subscribe(p=>console.log(">>> queryParams=", p))
}