weex 网络请求


<template>
 <div style = "justify-content:center">

   <text  class="label" >Vue.js Start Count</text>
   <text   class="count">{{count}}</text>
  
 </div>
</template>


<script >
  const stream = weex.requireModule('stream')
  export default {
    data(){
       return {
        count :'fetching...'
       }  
    },

    created(){
        stream.fetch({
          method:'GET',
          type:'json',
          url:'https://api.github.com/repos/vuejs/vue'
        },res => {
            if(res.ok){
              this.count = res.data.stargazers_count
            }else{
              this.count = '- unkonwn -'
            }
        } )
    }
  }

</script>

<style  scoped>

  .label {

      color:#666;
      text-align: center;
      font-size: 60px;

  }


  .count{

    color: #41B883;
    text-align: center;
    font-size: 100px;
    margin-top: 80px;
    margin-bottom: 100px;

  }

  
</style>










</script>
屏幕快照 2018-04-13 下午5.24.57.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容