最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
mpvue如何实现微信小程序快递单号查询 mpvue实现微信小程序快递单号查询代码
时间:2020-04-03 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下mpvue实现微信小程序快递单号查询代码,通过文中代码详细介绍了实现方法,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
mpvue是什么?
mpvue 是一套定位于开发小程序的前端开发框架,其核心目标是提高开发效率,增强开发体验。使用该框架,开发者只需初步了解小程序开发规范、熟悉 Vue.js 基本语法即可上手。框架提供了完整的 Vue.js 开发体验,开发者编写 Vue.js 代码,mpvue 将其解析转换为小程序并确保其正确运行。此外,框架还通过 vue-cli 工具向开发者提供 quick start 示例代码,开发者只需执行一条简单命令,即可获得可运行的项目。
使用快递100的接口 https://m.kuaidi100.com ,mpvue也是完全遵循原生微信小程序的语法,所以接口只允许https.~~~~
**在app.vue主文件里面定义一个globalData并初始化一个订单集合
globalData: {~~~~ orderInfo: [] }
**
mine页面
在此过程中我踩了一个大坑
引入主文件的全局数据需要和vue项目一样
import {app,globalData} from "../../app.vue"; ~~~~
两个简单输入框~~以及绑定了输入事件~~ mpvue也是完全支持v-model的~~~~
查询按钮~~~~
在methods里面写入相应的方法
methods:{ //上面的方法~~~~ bindChange: function (e) { console.log(e); var id; var value; id = e.currentTarget.id; value = e.mp.detail.value + ''; this.inputCon[id] = value; }, search: function () { var that = this; var type = that.inputCon.company; var postid = that.inputCon.orderId; var data = { 'type':type, 'postid':postid } console.log(this.globalData.queryInfo); console.log(data); this.globalData.queryInfo=data; console.log(app); wx.request({ url: 'https://m.kuaidi100.com/query', data: data, header: { 'content-type': 'application/json' }, success: (res)=> { var errTip = res.data.message; var orderInfo = res.data.data; console.log(orderInfo); if(orderInfo.length == 0) { console.log(errTip) // that.setData({ // errTip:errTip // }) this.errTip=errTip return } // that.setData({ // errTip:'' // }) this.errTip="" this.globalData.orderInfo = orderInfo; console.log( this.globalData.orderInfo) wx.navigateTo({ url: '../order/main' }); wx.setNavigationBarTitle({ title: data.postid }); } }) } }
点击查询按钮后跳订单详情页面~~~~
order页面内容~~
{{item.ftime}}: {{item.context}}
相关文章
- SpringBoot自定义bean绑定解析 10-24
- Javaweb工程运行报错HTTP Status 404解决教程 10-20
- JAVA获取jvm和操作系统相关信息方法 10-20
- BeanFactory和FactoryBean的区别讲解 10-20
- 微信小程序的宿主环境实现教程 10-10
- dispatchEvent解决重叠元素响应事件教程 10-10