arkts使用NavRouter进行页面切换时,NavRouter中的内容会残留到NavDestination,如
@Entry
@Component
struct Index{
build() {
Navigation() {
NavRouter(){
Text('Hello World')
NavDestination() {
Text('你好')
}.title('返回').height('100%').width('100%')
}
}
}
}
点击进行切换时会导致
上一个页面的'Hello World'会残留到NavDestination生成的页面中,NavDestination中的内容在生成前并没有刷新掉NavRouter中已有的内容
需要设置.backgroundColor()来强制刷新
@Entry
@Component
struct aaa{
build() {
Navigation() {
NavRouter(){
Text('Hello World')
NavDestination() {
Text('你好')
}.title('返回').height('100%').width('100%')
.backgroundColor(Color.White)
}
}
}
}