美文网首页
weex 网络请求

weex 网络请求

作者: 曾柏超 | 来源:发表于2018-04-13 17:25 被阅读0次

<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

相关文章

网友评论

      本文标题:weex 网络请求

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