/
githubmirror
/
taro
Обзор
Документация
Войти
/
githubmirror
/
taro
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/mini-program-example/src/pages/api/interface/windows/index.tsx
67 строк
2 KB
刘阳
同步harmony最新开发分支的代码:例子程序
02 апр 2024, 09:33
02 апр 2024, 09:33
d958330
Код
Авторство
О чём код?
import React from 'react' import Taro from '@tarojs/taro' import { View } from '@tarojs/components' import ButtonList from '@/components/buttonList' import { TestConsole } from '@/util/util' import './index.scss' /** * 界面-窗口 * @returns */ export default class Index extends React.Component { state = { list: [ { id: 'setWindowSize', func: null, }, { id: 'onWindowResize', func: (apiIndex) => { TestConsole.consoleTest('Taro.onWindowResize') if (!this.listenResize['registered']) { this.listenResize['registered'] = true Taro.onWindowResize(this.listenResize) Taro.showToast({ title: '注册监听', icon: 'success', }) } }, }, { id: 'offWindowResize', func: (apiIndex) => { TestConsole.consoleTest('Taro.offWindowResize') Taro.offWindowResize(this.listenResize) this.listenResize['registered'] = false Taro.showToast({ title: '取消注册', icon: 'success', }) }, }, { id: 'checkIsPictureInPictureActive', func: null, }, ], } listenResize(res) { Taro.showToast({ title: `高:${res.windowHeight},宽${res.windowWidth}`, }) } render() { const { list } = this.state return ( <View className='api-page'> <ButtonList buttonList={list} /> </View> ) } }