6
6
* @FilePath : /taro-react-native/src/pages/apis/pages/location/index/index.tsx
7
7
*/
8
8
import Taro from '@tarojs/taro' ;
9
- import { View , Button , Text } from '@tarojs/components' ;
9
+ import { useState } from "react" ;
10
+ import { View , Button } from '@tarojs/components' ;
11
+ import JSONTree from '../../../../components/jsontree' ;
10
12
11
13
import './index.scss'
12
14
13
15
const PageView = ( ) => {
16
+ const [ location , setLocation ] = useState ( { } ) ;
17
+ const [ location1 , setLocation1 ] = useState ( { } ) ;
18
+ const [ location2 , setLocation2 ] = useState ( { } ) ;
14
19
15
20
const _handleCallback1 = ( res ) => {
16
21
console . log ( "回调函数 C1" , res ) ;
22
+ setLocation1 ( res )
17
23
}
18
24
19
25
const _handleCallback2 = ( res ) => {
20
26
console . log ( "回调函数 C2" , res ) ;
27
+ setLocation2 ( res )
21
28
}
22
29
23
30
return (
@@ -29,25 +36,28 @@ const PageView = () => {
29
36
onClick = { ( ) => {
30
37
Taro . getLocation ( {
31
38
success : res => {
32
- console . log ( 999 , res )
39
+ setLocation ( res )
33
40
}
34
41
} )
35
42
} }
36
43
> Taro.getLocation</ Button >
44
+ < JSONTree data = { location } />
37
45
< Button
38
46
type = "primary"
39
47
className = "api-page-btn-success"
40
48
onClick = { ( ) => {
41
49
Taro . onLocationChange ( _handleCallback1 )
42
50
} }
43
51
> Taro.onLocationChange(C1)</ Button >
52
+ < JSONTree data = { location1 } />
44
53
< Button
45
54
type = "primary"
46
55
className = "api-page-btn-success"
47
56
onClick = { ( ) => {
48
57
Taro . onLocationChange ( _handleCallback2 )
49
58
} }
50
59
> Taro.onLocationChange(C2)</ Button >
60
+ < JSONTree data = { location2 } />
51
61
< Button
52
62
type = "primary"
53
63
className = "api-page-btn-warning"
0 commit comments