• 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 router from '@ohos.router';
17
18export default {
19    data() {
20        return {
21            title: '',
22            items: [],
23            pickerData: [],
24        };
25    },
26    onInit() {
27        this.title = 'Page List';
28        this.initializeItems();
29        this.initializePickerData();
30    },
31    onShow() {
32        this.$refs.swiperObj.rotation({ focus: true });
33    },
34    initializeItems() {
35        const fruits = [
36            'apple', 'banana', 'orange', 'grape', 'watermelon',
37            'pear', 'peach', 'cherry', 'mango', 'pineapple',
38            'strawberry', 'blueberry', 'raspberry', 'blackberry',
39            'kiwi', 'plum', 'apricot', 'nectarine', 'lychee', 'dragonFruit'
40        ];
41        this.items = [...fruits];
42    },
43    initializePickerData() {
44        const numbers = Array.from({ length: 9 }, (_, i) => (i + 1) * 10);
45        this.pickerData = [...numbers];
46    },
47    backPage() {
48        router.replaceUrl({
49            uri: 'pages/index/index',
50        });
51    },
52    onSelectSwiper() {
53        console.log('onSelectSwiper------');
54        this.focusComponent('swiperObj');
55    },
56    onSelectList() {
57        console.log('onSelectList------');
58        this.focusComponent('listObj');
59    },
60    onSelectPickerView() {
61        console.log('onSelectPickerView------');
62        this.focusComponent('pickerObj');
63    },
64    onSelectSlider(index) {
65        console.log(`onSelectSlider------ index: ${index}`);
66        const sliderRefs = ['sliderObj1', 'sliderObj2', 'sliderObj3'];
67        const refName = sliderRefs[index - 1];
68        if (refName && this.$refs[refName]) {
69            this.$refs[refName].rotation({ focus: true });
70        } else {
71            console.warn(`Slider with index ${index} not found.`);
72        }
73    },
74    focusComponent(refName) {
75        if (this.$refs[refName]) {
76            console.log('focusComponent------refName=', refName);
77            this.$refs[refName].rotation({ focus: true });
78        } else {
79            console.warn(`Component with ref "${refName}" not found.`);
80        }
81    },
82};