• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { UIUtils as utils } from '@ohos.arkui.StateManagement';
17
18class Info {
19  id: number = 0;
20  constructor(id: number) {
21    this.id = id;
22  }
23}
24
25@Entry
26@ComponentV2
27struct Index {
28  @Local message: Info = utils.makeObserved(new Info(20));
29  build() {
30    Column() {
31      Button(`change id`).onClick(() => {
32        this.message.id++;
33      })
34      Button(`change Info ${this.message.id}`).onClick(() => {
35        this.message = new Info(30);
36      })
37      Button(`change Info ${this.message.id}`).onClick(() => {
38        this.message = utils.makeObserved(new Info(30));
39      })
40    }
41  }
42}