Coder Social home page Coder Social logo

wechat's Introduction

笔记

{
  "pages":[
    "pages/index/index",
    "pages/logs/logs"
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "Weixin",
    "navigationBarTextStyle":"black"
  }
}
  • project.config.json 工具配置

  • page.json 每个页面配置

  • page.js JS逻辑交互

const app = getApp()
const globalData = app.globalData
Page({
  data: {
    msg: '',
  },
  onLoad: function () {
    // 页面渲染后 执行
  },
  clickMe: function() {
    this.setData({ msg: "Hello World" })
  }
})
  • app.js
App({
  globalData: {},
  onLaunch: function () {
    // 小程序启动之后 触发
  }
})
  • 模块
// common.js
function sayHello(name) {
  console.log(`Goodbye ${name} !`)
}
module.exports.sayHello = sayHello

// index.js
var common = require('common.js')
Page({
  helloMINA: function() {
    common.sayHello('MINA')
  }
})
  • 视图 WXML
<view wx:for="{{array}}"> {{item}} </view>

<view wx:if="{{view == 'WEBVIEW'}}"> WEBVIEW </view>
<view wx:elif="{{view == 'APP'}}"> APP </view>

<view style="color:{{color}};" />

<view data-alpha-beta="1" data-alphaBeta="2" bindtap="bindViewTap"> DataSet Test </view>
  • WXSS
/* 屏幕宽度750rpx */
@import "common.wxss";
wx.cloud.callFunction({
  // 云函数名称
  name: 'cloudFunc',
  // 传给云函数的参数
  data: {
    a: 1,
    b: 2,
  },
  success: function(res) {
    console.log(res.result) // 示例
  },
  fail: console.error
})
  • api
    • wx.getLocation 地理位置
    • wx.scanCode 扫一扫
    • wx.navigateTo 打开新页面
    • wx.navigatoBack 页面返回
    • wx.redirectTo 页面重定向
    • wx.reLaunch 重启动
    • wx.setStorageSync 本地储存

wechat's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.