/
githubmirror
/
taro
Обзор
Документация
Войти
/
githubmirror
/
taro
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/mini-program-example/src/components/callbackContents/index.tsx
49 строк
1 KB
刘阳
同步harmony最新开发分支的代码:例子程序
02 апр 2024, 09:33
02 апр 2024, 09:33
d958330
Код
Авторство
О чём код?
import React from 'react' import Taro from '@tarojs/taro' import { View, Text } from '@tarojs/components' import './index.scss' /** * 回调结构内容 * @returns */ interface Props { testApi: string callbackRes: any } export default class Index extends React.Component<Props> { state = {} stringify = (object) => { // console.log(object) const cache = new Map() const JSONStr = JSON.stringify(object, (key, value) => { if (value === undefined) { return 'undefined' } if (typeof value == 'function') { return 'function' } if (typeof value === 'object' && value !== null) { if (cache.has(value)) { return } cache.set(value, value) } return value }) cache.clear() return JSONStr } render() { const { testApi, callbackRes } = this.props return ( <View className='callback-content'> <View className='callback-res' id={`${testApi}-callback`}> {this.stringify(callbackRes)} </View> </View> ) } }