Commit 9c54e58 1 parent c50504d commit 9c54e58 Copy full SHA for 9c54e58
File tree 1 file changed +21
-1
lines changed
src/pages/apis/pages/media/image
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 2
2
* @Author : iChengbo
3
3
* @Date : 2021-07-29 16:44:12
4
4
* @LastEditors : iChengbo
5
- * @LastEditTime : 2021-07-29 17:57:22
5
+ * @LastEditTime : 2021-08-12 18:22:31
6
6
* @FilePath : /taro-react-native/src/pages/apis/pages/media/image/index.tsx
7
7
*/
8
8
import { useState } from 'react' ;
@@ -104,6 +104,26 @@ const PageView = () => {
104
104
} )
105
105
} }
106
106
> Taro.chooseImage</ Button >
107
+ < Button
108
+ type = "primary"
109
+ className = "api-page-btn-success"
110
+ onClick = { ( ) => {
111
+ Taro . downloadFile ( {
112
+ url : 'https://pic1.58cdn.com.cn/nowater/fangfe/n_v2beae27152fcd4d118b60d5284e29d9c9.png' ,
113
+ success : res => {
114
+ console . log ( res ) ;
115
+ if ( res . statusCode == 200 ) {
116
+ Taro . showToast ( { title : '下载完成(临时文件)' , icon : 'none' } ) ;
117
+ setSource ( res . tempFilePath ) ;
118
+ }
119
+ } ,
120
+ fail : err => {
121
+ console . log ( '下载失败:' , err ) ;
122
+ Taro . showToast ( { title : '下载失败' , icon : 'none' } ) ;
123
+ }
124
+ } ) ;
125
+ } }
126
+ > Taro.downloadFile</ Button >
107
127
</ View >
108
128
)
109
129
}
You can’t perform that action at this time.
0 commit comments