微信小程序8 界面api
来源:互联网 发布:淘宝买游戏账号被骗 编辑:程序博客网 时间:2024/06/06 20:44
交互反馈
wx.showToast(OBJECT)
显示消息提示框
wx.showToast({ title: '成功', icon: 'success', duration: 2000})
OBJECT参数说明:
wx.showLoading(OBJECT)
基础库 1.1.0 开始支持,低版本需做兼容处理
显示 loading 提示框, 需主动调用 wx.hideLoading 才能关闭提示框
wx.hideToast()
隐藏消息提示框
wx.hideLoading()
基础库 1.1.0 开始支持,低版本需做兼容处理
隐藏 loading 提示框
wx.showLoading({ title: '加载中',})setTimeout(function(){ wx.hideLoading()},2000)
wx.showModal(OBJECT)
显示模态弹窗
wx.showModal({ title: '提示', content: '这是一个模态弹窗', success: function(res) { if (res.confirm) { console.log('用户点击确定') } else if (res.cancel) { console.log('用户点击取消') } }})
OBJECT参数说明:
success返回参数说明:
wx.showActionSheet(OBJECT)
显示操作菜单
wx.showActionSheet({ itemList: ['A', 'B', 'C'], success: function(res) { console.log(res.tapIndex) }, fail: function(res) { console.log(res.errMsg) }})
OBJECT参数说明:
success返回参数说明:
导航
wx.navigateTo(OBJECT)
保留当前页面,跳转到应用内的某个页面,使用wx.navigateBack
可以返回到原页面。 可以返回!!!!!
wx.navigateTo({ url: 'test?id=1'})
//test.jsPage({ onLoad: function(option){ console.log(option.query) }})
注意:为了不让用户在使用小程序时造成困扰,我们规定页面路径只能是五层,请尽量避免多层级的交互方式。wx.redirectTo(OBJECT)
关闭当前页面,跳转到应用内的某个页面。
wx.reLaunch(OBJECT)
基础库 1.1.0 开始支持,低版本需做兼容处理
关闭所有页面,打开到应用内的某个页面。
示例代码:
wx.reLaunch({ url: 'test?id=1'})
//test.jsPage({ onLoad: function(option){ console.log(option.query) }})
wx.switchTab(OBJECT)
跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
{ "tabBar": { "list": [{ "pagePath": "index", "text": "首页" },{ "pagePath": "other", "text": "其他" }] }}
wx.switchTab({ url: '/index'})
wx.navigateBack(OBJECT)
关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages()
) 获取当前的页面栈,决定需要返回几层。
// 注意:调用 navigateTo 跳转时,调用该方法的页面会被加入堆栈,而 redirectTo 方法则不会。见下方示例代码// 此处是A页面wx.navigateTo({ url: 'B?id=1'})// 此处是B页面wx.navigateTo({ url: 'C?id=1'})// 在C页面内 navigateBack,将返回A页面wx.navigateBack({ delta: 2})
OBJECT 参数说明:
设置导航条
wx.setNavigationBarTitle(OBJECT)
动态设置当前页面的标题。
wx.setNavigationBarTitle({ title: '当前页面'})
wx.showNavigationBarLoading()
在当前页面显示导航条加载动画。
wx.hideNavigationBarLoading()
隐藏导航条加载动画。
wx.setNavigationBarColor(OBJECT)
wx.setNavigationBarColor({ frontColor: '#ffffff', backgroundColor: '#ff0000', animation: { duration: 400, timingFunc: 'easeIn' }})
frontColorString是前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000backgroundColorString是背景颜色值,有效值为十六进制颜色animationObject否动画效果animation.durationNumber否动画变化时间,默认0,单位:毫秒animation.timingFuncString否动画变化方式,默认 linearanimation.timingFunc 有效值:
动画
wx.createAnimation(OBJECT)
创建一个动画实例animation。调用实例的方法来描述动画。最后通过动画实例的export
方法导出动画数据传递给组件的animation
属性var animation = wx.createAnimation({ transformOrigin: "50% 50%", duration: 1000, timingFunction: "ease", delay: 0})
以下为各种动画的调用
<view animation="{{animationData}}" style="background:red;height:100rpx;width:100rpx"></view>
Page({ data: { animationData: {} }, onShow: function(){ var animation = wx.createAnimation({ duration: 1000, timingFunction: 'ease', }) this.animation = animation animation.scale(2,2).rotate(45).step() this.setData({ animationData:animation.export() }) setTimeout(function() { animation.translate(30).step() this.setData({ animationData:animation.export() }) }.bind(this), 1000) }, rotateAndScale: function () { // 旋转同时放大 this.animation.rotate(45).scale(2, 2).step() this.setData({ animationData: this.animation.export() }) }, rotateThenScale: function () { // 先旋转后放大 this.animation.rotate(45).step() this.animation.scale(2, 2).step() this.setData({ animationData: this.animation.export() }) }, rotateAndScaleThenTranslate: function () { // 先旋转同时放大,然后平移 this.animation.rotate(45).scale(2, 2).step() this.animation.translate(100, 100).step({ duration: 1000 }) this.setData({ animationData: this.animation.export() }) }})
绘图
待补充....
阅读全文
0 0
- 微信小程序8 界面api
- 微信小程序-欢迎界面
- 微信小程序-欢迎界面
- 小程序文档整理之 -- API(界面)
- 微信小程序8 位置与设备api
- 微信小程序 Image API
- 微信小程序 Audio API
- 微信小程序 Video API
- 微信小程序 Storage API
- 微信小程序 location API
- 微信小程序 navigation API
- 微信小程序 animation API
- 微信小程序 canvas API
- 微信小程序文档api
- 微信小程序位置API
- 微信小程序 animation API
- 微信小程序API~GET
- 微信小程序------API
- 深度学习--Batch_Normlization
- day3代码
- “RPC好,还是RESTful好?”
- 牛客网-剑指offer-10-矩形覆盖
- HDU 6194 string string string :后缀数组+单调队列 | 后缀自动机
- 微信小程序8 界面api
- Project facet Java version 1.8 is not supported.
- 无穷小放飞互联网,赶超美日不是梦
- 最新pycharm破解(亲试有效)
- 多线程
- SpringBoot 使用fastjson初识
- PyQt5介绍
- 如何在其他项目调用webservice 发布的soap风格的接口
- webService的soap风格的接口的安全问题