zoukankan      html  css  js  c++  java
  • 微信小程序ajax请求数据及一些方法

    <viewclass="flex-wrp"style="flex-direction:row;"wx:for="{{Industry}}">
    <viewclass="flex-item bc_green">
    ({{index}}){{item.date}} {{item.high}} {{item.low}}
    {{item.notice}}
    </view>
    </view>
     
    <viewclass="tip"hidden="{{isshow}}">数据加载完成</view>

    js

    // pages/list/list.js
    Page({
     
      /**
       * 页面的初始数据
       */
      data: {
        Industry:{},
        isshow:true
      },
     
      /**
       * 生命周期函数--监听页面加载
       */
      onLoad: function (res) {
        var that = this 
        wx.request({
          url: 'http://www.sojson.com/open/api/weather/json.shtml?city=杭州', 
          header: {
            'content-type': 'application/json' // 默认值
          },
          success: function (res) {
            console.log(res.data.data.forecast)
            that.setData({
              Industry: res.data.data.forecast
            })  
          },
          fail: function () {
           console.log("fail")
          },
          complete: function () {
             that.setData({
               isshow:false
             })
          } 
        })
      },
     
      /**
       * 生命周期函数--监听页面初次渲染完成
       */
      onReady: function () {
      
      },
     
      /**
       * 生命周期函数--监听页面显示
       */
      onShow: function () {
      
      },
     
      /**
       * 生命周期函数--监听页面隐藏
       */
      onHide: function () {
      
      },
     
      /**
       * 生命周期函数--监听页面卸载
       */
      onUnload: function () {
      
      },
     
      /**
       * 页面相关事件处理函数--监听用户下拉动作
       */
      onPullDownRefresh: function () {
      
      },
     
      /**
       * 页面上拉触底事件的处理函数
       */
      onReachBottom: function () {
      
      },
     
      /**
       * 用户点击右上角分享
       */
      onShareAppMessage: function () {
      
      }
  • 相关阅读:
    Solr部署准备
    linux 安装SVN
    构建高性能web站点--读书大纲
    webapi请求
    搭建git服务器
    git常用知识整理
    Ruby on Rail 开发入门
    Ruby on rail 开发准备
    PHP模拟请求雅虎竞标商品加价
    JAVA httpURLConnection curl
  • 原文地址:https://www.cnblogs.com/zyfeng/p/11375449.html
Copyright © 2011-2022 走看看