Wechat Javascript code snippets for VSCode
Latest commit 6b765ba Nov 7, 2016 @coderfe 0.1.8
Permalink
Failed to load latest commit information.
.vscode add vscode tasks Oct 28, 2016
images version@0.0.1 Oct 13, 2016
snippets add new snippets Nov 7, 2016
.editorconfig '0.1.4' Oct 23, 2016
.gitignore version@0.0.1 Oct 13, 2016
.vscodeignore '0.1.6' Oct 24, 2016
CHANGELOG.md add new snippets Nov 7, 2016
LICENSE version@0.0.1 Oct 13, 2016
README.md '0.1.6' Oct 24, 2016
package.json 0.1.8 Nov 7, 2016

README.md

微信小程序 API 代码片段

为 VSCode 提供微信小程序 API 提示及代码片段

version installs

安装

  1. 打开编辑器,Ctrl + Shift + X,搜索 weapp-api
  2. 点击 install

使用

小程序 API 提示

键入关键词 wx,就会出现提示,然后回车。关键词不区分大小写。

vscode-weapp-api-snippets

API 代码示例

  • wxapp

    App({
      onLaunch: function() {
    
      },
      onShow: function() {
    
      },
      onHide: function() {
    
      },
      globalData: globalData
    })
  • wxpage

    Page({
      data: {
    
      },
      onLoad: function(options) {
        //Do some initialize when page load.
    
      },
      onReady: function() {
        //Do some when page ready.
    
      },
      onShow: function() {
        //Do some when page show.
    
      },
      onHide: function() {
        //Do some when page hide.
    
      },
      onUnload: function() {
        //Do some when page unload.
    
      },
      onPullDownRefresh: function() {
        //Do some when page pull down.
    
      }
    })
  • wxgetlocation

    wx.getLocation({
      type: 'wgs84',
      success: function(res) {
        var latitude = res.latitude
        var longitude = res.longitude
      },
    })
  • wxrequest

    wx.request({
      url: '',
      header: {
        'Content-Type': 'application/json'
      },
      success: function(res) {
    
      }
    })
  • ······more

app.json 配置提示

app.json 中请注意添加逗号。关键词只有 5 个:pages / window / tabbar / network / debug

vscode-weapp-json-snippets

app.json 代码示例

  • page

    "pages": [
        "pages/index/index",
        "add your pages path"
    ]
  • window

    "window": {
        "navigationBarBackgroundColor": "#000000",
        "navigationBarTextStyle": "white",
        "navigationBarTitleText": "Wechat",
        "backgroundColor": "#ffffff",
        "backgroundTextStyle": "dark",
        "enablePullDownRefresh": false
    }
  • tabbar

    "tabBar": {
        "color": "#cccccc",
        "selectedColor": "#000000",
        "backgroundColor": "#ffffff",
        "borderStyle": "black",
        // list中至少2个对象,最多5个对象
        "list": [{
          "pagePath": "pages/index/index",
          "text": "text",
          "iconPath": "iconPath",
          "selectedIconPath": "selectedIconPath"
        }]
    }
  • network

    "networkTimeOut": {
        "request": $1,
        "connectSocket": $2,
        "uploadFile": $3,
        "downloadFile": $4
    }
  • debug

    "debug": true

    Enjoy!