weex发起网络请求

作者: 十一岁的加重 | 来源:发表于2017-10-16 11:15 被阅读55次
image.png image.png image.png
<template>
    <div class="divTest" @click="clickNet2">
        <text>Hello Weex!</text>
    </div>
</template>

<script>

    var modal = weex.requireModule('modal')
    var stream = weex.requireModule('stream')

    module.exports = {
        data: {},
        methods: {

          clickNet:function (e) {
              stream.fetch({
                  method: 'GET',
                  url: 'https://www.baidu.com/'
              },function(res){
                  modal.toast({
                      message: res.data,
                      duration: 0.3
                  })
              })
          },
            clickNet2:function (e) {
                stream.fetch({
                    method: 'GET',
                    url: 'https://www.baidu.com/'
                },res => {
                    modal.toast({
                        message: res.data,
                        duration: 0.9
                    })
                })
            }
        }
    }
</script>

<style>
    .divTest {
        align-items:center;
        justify-content: center;
        width: 750px;
        height: 400px;
        background-color: azure;
    }
</style>

已经可以访问到网络返回的数据 了

image.png

相关文章

  • weex发起网络请求

    已经可以访问到网络返回的数据 了

  • iOS 中 Weex网络监听、设置Cookie

    写在最开始,项目中需要监听Weex所有网络请求,设置cookie,监听网络异常,帮助团队查找weex网络问题等等,...

  • weex 网络请求

  • 发起网络请求

    小程序网络请求 data数据说明: 最终发送给服务器的数据是 String 类型,如果传入的 data 不是 St...

  • Redux-学习经验

    进行网络请求 发起网络请求的操作通常放在组件的componentDidMount方法中,使用redux进行网络请求...

  • Dio二次封装

    HttpRequest封装 HttpConfig封装 发起网络请求:

  • 在微信小程序中创建一个统一的网络请求工具类

    在小程序中,发起网络请求,都是用小程序提供的 wx.request(OBJECT) 来发起网络请求。 但是在开发的...

  • 小程序二

    11.网络数据请求 1.发起GET请求 2.发起post请求 声明式导航 1.导航到 tabBar 页面 在使用 ...

  • okHttp发起网络请求

    第一步,肯定是添加依赖了,这个有在线的和无线的两种,具体我就不多说了,有需求的可以看一篇讲解添加依赖的文章 Okh...

  • iOS 网络优化

    一.分析网络请求流程及耗时 1、网络请求的过程 发起请求 -> 域名解析 -> tcp三次握手 ( -> tls握...

网友评论

    本文标题:weex发起网络请求

    本文链接:https://www.haomeiwen.com/subject/hwlkuxtx.html