1# ArkUI子系统ChangeLog 2## cl.arkui.1 Navigation、NavDestination的title和menus接口支持Resource类型资源 3**访问级别** 4 5公开接口 6 7**变更原因** 8 9基础能力增强,Navigation、navdestination的title和menus接口支持Resource类型 10 11**变更影响** 12 13该变更为不兼容变更。 14 15由于NavigationMenuItem变量类型变更为 string | Resource,不再与单一变量类型string相匹配,因此将NavigationMenuItem赋值给一个string类型变量,程序会编译报错。 16 17``` 18const myIcon: NavigationMenuItem = { value: "图标", icon: "https://example.png"} 19const myString: string = myIcon.value 20 21``` 22 23**起始API Level** 24 259 26 27**变更发生版本** 28 29从OpenHarmony SDK 5.0.0.42 版本开始。 30 31**变更的接口/组件** 32 33Navigation/NavDestination 34 35**适配指导** 36 37``` 38// navigation.ets 39// 使用resource类型资源赋值给Navigation/NavDestination的title及menu接口 40Navigation() { 41 // xxx 42} 43.title($r('app.string.MyTestNavigationTitle')) // 可直接将resource类型资源传递给title接口 44// menus内的item设置可直接支持resource类型资源 45.menus([ 46 { 47 value: $r("app.string.MyTestMenuValue1"), 48 icon: $r("app.media.1") 49 }, 50 { 51 value: $r("app.string.MyTestMenuValue2"), 52 icon: $r("app.media.2") 53 }, 54 { 55 value: $r("app.string.MyTestMenuValue3"), 56 icon: $r("app.media.3") 57 } 58]) 59``` 60 61 62``` 63// navDestination.ets 64// Navigation及NavDestination的CommonTitle类型,支持设置resource资源 65@State commonTitle: NavDestinationCommonTitle = { main: $r('app.string.MyTestNavigationTitle'), sub: $r('app.string.MyTestNavigationTitle')} 66NavDestination() { 67 // xxx 68} 69.menus([ 70 { 71 value: $r("app.string.MyTestMenuValue1"), 72 icon: $r("app.media.4") 73 }, 74 { 75 value: $r("app.string.MyTestMenuValue2"), 76 icon: $r("app.media.5") 77 }, 78 { 79 value: $r("app.string.MyTestMenuValue3"), 80 icon: $r("app.media.6") 81 } 82]) 83.title(this.commonTitle) 84``` 85 86## cl.arkui.2 优化状态变量场景下ForEach的冗余刷新行为 87 88**访问级别** 89 90公开接口 91 92**变更原因** 93 94开发者使用ForEach,在旧节点下树的时候会被刷新一次,属于规格外的行为,当刷新调用方法中存在对全局变量的修改时会发生异常。 95 96**变更影响** 97 98该变更为不兼容变更。 99 100变更前:开发者在使用ForEach时,节点下树的时候会被刷新一次。 101 102变更后:开发者在使用ForEach时,节点下树的时候不会被刷新。 103 104**起始API Level** 105 1069 107 108**变更发生版本** 109 110从OpenHarmony SDK 5.0.0.42开始。 111 112**变更的接口/组件** 113 114ForEach 115 116**适配指导** 117 118之前使用ForEach涉及节点刷新时调用的方法存在对全局变量值修改的,需要根据具体情况对代码进行相应的修改,使当前修改等效于原来的两次修改叠加,以保证效果不变。 119 120示例: 121 122变更前: 123```ts 124let g_data = 0; 125 126@Entry 127@Component 128struct MyComponent { 129 @State simpleList: number[] = [0, 1, 2] 130 131 fn(item: number, index: number) { 132 g_data++; 133 return 80; 134 } 135 136 build() { 137 Row() { 138 Column() { 139 Button('click button []') 140 .onClick(() => { 141 this.simpleList = [4, 5, 6] 142 }) 143 ForEach(this.simpleList, (item: number, index: number) => { 144 Text(item.toString()) 145 .fontSize(this.fn(item, index)) 146 .onAppear(()=>{ 147 console.log('g_data: ' + g_data); 148 }) 149 }, (item: string) => item) 150 } 151 .width('100%') 152 .height('100%') 153 } 154 } 155} 156``` 157 158变更后: 159```ts 160let g_data = 0; 161 162@Entry 163@Component 164struct MyComponent { 165 @State simpleList: number[] = [0, 1, 2] 166 167 fn(item: number, index: number) { 168 // 变更前总会调用两次,变更后只会调用一次,保证变更前后效果一致 169 g_data+=2; 170 return 80; 171 } 172 173 build() { 174 Row() { 175 Column() { 176 Button('click button []') 177 .onClick(() => { 178 this.simpleList = [4, 5, 6] 179 }) 180 ForEach(this.simpleList, (item: number, index: number) => { 181 Text(item.toString()) 182 .fontSize(this.fn(item, index)) 183 .onAppear(()=>{ 184 console.log('g_data: ' + g_data); 185 }) 186 }, (item: string) => item) 187 } 188 .width('100%') 189 .height('100%') 190 } 191 } 192} 193``` 194 195## cl.arkui.3 Navdestination的Dialog模式默认支持系统动画 196 197**访问级别** 198 199公开接口 200 201**变更原因** 202 203Navdestination的Dialog模式支持系统动画 204 205**变更影响** 206该变更为不兼容变更。 207 208变更前:Navdestination的Dialog模式,无系统默认动画。 209 210变更后:Navdestination的Dialog模式,默认带有系统转场动画。 211 212| 变更前 | 变更后 | 213|---------|---------| 214|  |  | 215 216**起始API Level** 217 2189 219 220**变更发生版本** 221 222从OpenHarmony SDK 5.0.0.42开始。 223 224**变更的接口/组件** 225 226Navdestination 227 228**适配指导** 229 230开发者可以通过在pop与push接口中设置false关闭Navdestination的系统默认动画。 231 232示例: 233 234其中,NavDestination的内容区需自行构造,可参考[开发指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/ui/arkts-navigation-navigation.md)。 235 236```ts 237@Entry 238@Component 239 240struct NavigationDemo { 241 @State pageInfos: NavPathStack = new NavPathStack(); 242 243 @Builder 244 pageOneTmp() { 245 NavDestination() { 246 // ... 247 // 需自行构造NavDestination 248 } 249 .title("PageOne") 250 .mode(NavDestinationMode.DIALOG) 251 } 252 253 @Builder 254 PageMap(name: string, param: object) { 255 if (name === 'pageOne') { 256 this.pageOneTmp() 257 } 258 } 259 260 build() { 261 Column({ space: 10 }) { 262 Button('Pop Dialog') 263 .onClick(() => { 264 // set false to close system pop animation 265 this.pageInfos.pop(false) 266 }) 267 Button('Push Dialog') 268 .onClick(() => { 269 // set false to close system push animation 270 this.pageInfos.pushPath({ name: 'pageOne' }, false) 271 }) 272 Navigation(this.pageInfos) { 273 Column({ space: 10 }) { 274 Text("This is navigation").fontSize(60).align(Alignment.Center) 275 } 276 } 277 .height(500) 278 .backgroundColor(Color.Grey) 279 .navDestination(this.PageMap) 280 }.height(50) 281 } 282} 283```