主要源码如下:

//index.js

Page({

 data: {

   youbian: null,

   resultInfo: null

  },

  //查询按钮点击处理函数

 btnClick:function(){

    var thispage=this;

    this.getYouZhengInfo(this.data.youbian,function(data){thispage.setData({resultInfo:data});

   }

)},

  //文本框输入处理函数

  inputNumber:function(e){

    this.setData({youbian:e.detail.value})

  },

  //获取邮编地区信息函数

 getYouZhengInfo: function (num, callback) {

   wx.request({

     url: 'http://v.juhe.cn/postcode/query?key=7f36d1d1aca33c453fc5e8403cd0017e&postcode=' + num,

     data: {

       x: '',

       y: ''

     },

     header: {

     },

     success: function (result) {

       callback(result.data)

     }

   })

  }

  })

 说明:(回调函数的使用)

微信小程序实战:查询邮政编码归属地

相关文章:

  • 2021-09-27
  • 2021-06-26
  • 2021-04-06
  • 2022-12-23
  • 2021-11-23
  • 2021-06-25
  • 2022-01-10
猜你喜欢
  • 2021-12-04
  • 2021-11-23
  • 2022-12-23
  • 2021-12-05
  • 2021-11-23
  • 2021-11-28
相关资源
相似解决方案