|
@@ -0,0 +1,37 @@
|
|
1
|
+import React from 'react';
|
|
2
|
+import Taro from '@tarojs/taro';
|
|
3
|
+import { View, Image, ScrollView } from '@tarojs/components';
|
|
4
|
+
|
|
5
|
+export default function (props) {
|
|
6
|
+
|
|
7
|
+ const [imgStyle, setStyle] = React.useState({ height: '100%' });
|
|
8
|
+
|
|
9
|
+ const onLoad = e => {
|
|
10
|
+ const { width, height } = e.detail;
|
|
11
|
+
|
|
12
|
+ if (width > 0 && height > 0) {
|
|
13
|
+ Taro.getSystemInfo({
|
|
14
|
+ success: res => {
|
|
15
|
+ const windowWidth = res.windowWidth;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+ setStyle({
|
|
19
|
+ height: `${windowWidth * height / width}px`,
|
|
20
|
+ });
|
|
21
|
+ }
|
|
22
|
+ })
|
|
23
|
+ }
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ return (
|
|
27
|
+ <View className='page-index'>
|
|
28
|
+ <ScrollView scrollY style={{ height: '100%' }}>
|
|
29
|
+ <Image
|
|
30
|
+ src='https://dz-machinery.oss-cn-nanjing.aliyuncs.com/images/news-demo1.png'
|
|
31
|
+ style={{ display: 'block', width: '100%', ...imgStyle }}
|
|
32
|
+ onLoad={onLoad}
|
|
33
|
+ />
|
|
34
|
+ </ScrollView>
|
|
35
|
+ </View>
|
|
36
|
+ );
|
|
37
|
+}
|