File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 <textarea :value =" res" ></textarea >
1010 </view >
1111 <view class =" uni-btn-v uni-common-mt" >
12- <button type =" primary" @tap = " makeRequest " :loading =" loading" >发起请求</button >
12+ <button type =" primary" @click = " sendRequest " :loading =" loading" >发起请求</button >
1313 </view >
1414 </view >
1515 </view >
1616</template >
1717<script >
18- const requestUrl = " https://unidemo.dcloud.net.cn/ajax/echo/text?name=uni-app"
18+ const requestUrl = ' https://unidemo.dcloud.net.cn/ajax/echo/text?name=uni-app'
1919 const duration = 2000
2020 export default {
2121 data () {
2222 return {
2323 title: ' request' ,
2424 loading: false ,
25- res: " "
25+ res: ' '
2626 }
2727 },
2828 methods: {
29- makeRequest : function () {
29+ sendRequest : function () {
3030 this .loading = true
3131 uni .request ({
3232 url: requestUrl,
33- dataType: ' text' ,
33+ dataType: ' text' ,
3434 data: {
3535 noncestr: Date .now ()
3636 },
3737 success : (res ) => {
38+ console .log (' request success' , res)
3839 uni .showToast ({
3940 title: ' 请求成功' ,
4041 icon: ' success' ,
4142 mask: true ,
4243 duration: duration
43- })
44+ });
4445 this .res = ' 请求结果 : ' + JSON .stringify (res);
45- console .log (' request success' , res)
4646 },
4747 fail : (err ) => {
4848 console .log (' request fail' , err);
4949 uni .showModal ({
50- content: err .errMsg ,
51- showCancel: false
52- })
50+ content: err .errMsg ,
51+ showCancel: false
52+ });
5353 },
54- complete : () => {
55- this .loading = false
54+ complete : () => {
55+ this .loading = false ;
5656 }
57- })
57+ });
5858 }
5959 }
6060 }
61- </script >
62-
61+ </script >
You can’t perform that action at this time.
0 commit comments