微信小程序笔记

来源:互联网 发布:火影手游网络连接异常 编辑:程序博客网 时间:2024/06/05 04:48
  1. app.json的pages里配置各个要显示的界面
  2. 在引用外部的js文件的时候用import util from '../../../utils/util.js' 对应的util.js文件里的


    module.exports = {
    getDateList,
    filterContent,
    formatMakettime
    }
    调用的使用用util.getDateList();

     success: (res) => {        if (res.data.res === 0) {          let serial = res.data.setData          serial.content = util.filterContent(serial.content)          serial.maketime = util.formatMakettime(serial.maketime)          this.setData({ serial })        }      }

3.app.js 里的内容是App({}),pages 里的各个js文件的是page({})
4.在引入外部的wxml文件的时候

<import src="templates/essayItem.wxml"/><template is="essay-item" data="{{item: articles['essay'][idx]}}"/>

is里的要和import里的一样一个是驼峰,一个是用“-”
5.在view里data-id="{{item.content_id}}bindtap="tapEssay" 然后在bindtap方法里用let id = e.currentTarget.dataset.id 调用
6.wx.request(objict) url 是必须传的 wx.uploadFile(object) url、 filepath、name 是必须传的 wx.downloadFile(object) url websocket

1. wx.connectSocket() 2. wx.onSocketOpen(callback) 在callback里写下一步发送 3. wx.sendSocketMessage(obj) 其中data是string或者arrayBuffer 4. wx.onSocketMessag(callback) 5. wx.closeSocket() 6. wx.onSocketClose()

7.

wx.chooseImage(OBJECT)  wx.playVoice(OBJECT)      wx.playBackgroundAudio(OBJECT)  wx.chooseVideo(OBJECT)  wx.createVideoContext(videoId) wx.saveFile(OBJECT) wx.setStorageSync(KEY,DATA)  wx.getLocation(OBJECT) wx.chooseLocation(OBJECT)打开地图选择位置 wx.createMapContext(mapId)创建并返回 map 上下文 mapContext 对象

8.

wx.navigateTo(OBJECT) 保留当前页面,跳转到应用内的某个页面使用wx.navigateBack可以返回到原页面  wx.redirectTo(OBJECT)关闭当前页面,跳转到应用内的某个页面。wx.reLaunch(OBJECT) 关闭所有页面,打开到应用内的某个页面。wx.switchTab(OBJECT)跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面

9.

wx.makePhoneCall(OBJECT)  wx.getSystemInfo(OBJECT)

10.

<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()    })  }})

11.

wx.pageScrollTo(OBJECT)wx.pageScrollTo({  scrollTop: 0})
wx.createSelectorQuery()
原创粉丝点击