国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ?? ??? ?? ???? ?? WeChat ?? ???? ??? ?? ?? ??? ?? ??? ?? ? ?? ??

WeChat ?? ???? ??? ?? ?? ??? ?? ??? ?? ? ?? ??

Feb 22, 2017 pm 02:17 PM

? ?? ?? ?? ?? ????? ????? ????? ?? ??? ??? ?? ??? ?? ?? ??? ???? ????. ??? ??? ????

?? ?? ????? ????? ???? ??? ????

WeChat ???? ????? ??? ???? ?? ?? ?????. ?? ??? ???? ??? ???? ???? ??? ?? ?? ?????.

? ?? ??? ?? ?? ????? ??? ?? ??? ?????. ???? ???? ??? ??? ?? ? ??? ?????? ?????.

??? ?? ??:

微信 小程序前端源碼詳解及實(shí)例分析

?? app.js ??? ?? app(obj)? ?? ????? ??? ???. . ???? ???? ?? ?? ???? ?? ????? ?????. ?? ??? ?? ??? getApp()? ?? ? ????? ?? ?? (getApp().globalData)

//app.js
App({
 onLaunch: function () {
  //調(diào)用API從本地緩存中獲取數(shù)據(jù)
  var logs = wx.getStorageSync('logs') || []
  logs.unshift(Date.now())
  wx.setStorageSync('logs', logs)
 },
 getUserInfo:function(cb){
  var that = this
  if(this.globalData.userInfo){
   typeof cb == "function" && cb(this.globalData.userInfo)
  }else{
   //調(diào)用登錄接口
   wx.login({
    success: function () {
     wx.getUserInfo({
      success: function (res) {
       that.globalData.userInfo = res.userInfo
       typeof cb == "function" && cb(that.globalData.userInfo)
      }
     })
    }
   })
  }
 },
 globalData:{
  userInfo:null
 }
})

app.js? ?? ??? ???? ??? API ??? ???? ???? ? ??? ?? ????.

onLaunch ?? ??? ?? ???? ???? ??? ? ? ? ???? ????, ? ??? ????? ???? ???

?? ???? ??? ??? onLaunch? ???? ????.

varlogs=wx.getStorageSync('logs') || [] ?? ???? ?? ??? ?????. ?? ?? ??? log=[]? ???? localStorage? ??? ??? ????. HTML5

logs.unshift(Date.now()) ?? ??? ??? ??? ?????.

wx.setStorageSync('logs',logs) ???? ?? ??? ?????. wx? ?? ????? ?? ???? wx.getStorageSync('logs')? ?? ???? ?? ?? ???? ?? ? ????.

getUserInfo ??,

???? ? ? ???, ?? ???? ??? ??? ?? ?? ???, ?? ? ??? ???? ?? ?????. ??? ??? ?? ?? ?????? ?? ????? ???? ?? ? ???? ????. ?? ?????? getApp().getUserInfo(function(userinfo){console.log(userinfo);})? ?? ? ???? ???? ??? ??? ????.

getUserInfo:function(cb){//參數(shù)為cb,類型為函數(shù)
  var that = this
  if(this.globalData.userInfo){//用戶信息不為空
   typeof cb == "function" && cb(this.globalData.userInfo)//如果參數(shù)cb的類型為函數(shù),那么執(zhí)行cb,獲取用戶信息;
  }else{//如果用戶信息為空,也就是說第一次調(diào)用getUserInfo,會(huì)調(diào)用用戶登錄接口。
   wx.login({
    success: function () {
     wx.getUserInfo({
      success: function (res) {
         console.log(res)
       that.globalData.userInfo = res.userInfo//把用戶信息賦給globalData,如果再次調(diào)用getUserInfo函數(shù)的時(shí)候,不需要調(diào)用登錄接口
       typeof cb == "function" && cb(that.globalData.userInfo)//如果參數(shù)cb類型為函數(shù),執(zhí)行cb,獲取用戶信息
      }
     })
    }
   })
  }
 }

globalData

??? ?? ???? ???? ? ?????.

? ?? ??? ??? ?? app.json ??? ???? ???? ? ??? ??? WeChat ???? ????? ????, ??? ??? ??, ? ??? ????, ???? ?? ??? ????, ?? ?? ???? ?? ????.

?? ??? ??

??? ??

? ????? ????. ??? ??? ?? ????? ???? ???? ???? ??? ?? ?????. ?? ????.

{
 "pages":[
  "pages/index/index",
  "pages/logs/logs"
 ],
 "window":{
  "backgroundTextStyle":"light",
  "navigationBarBackgroundColor": "#fff",
  "navigationBarTitleText": "WeChat",
  "navigationBarTextStyle":"black"
 }
}

?? ?? ???? ??? ? ?? ??? ?????. WeChat ???? ?? ??????? ? ???? ??? js, wxss, wxml? ?? ??? ?? ??? ?? ??? ????.

?? ??????? ?? ???? ??? ??? ???????. index ?? ???? index.js, index.wxml ? index.wxss?? ? ?? ?? ??? ????. ?? ????? js, css, html ??? ???? ??? ??? ?? ?? ??? ??? ?????. js ? ????? ?? ??? ?? ??? wxml ?? ??? ???? js ? ?????? ??? ???? ??? ? ????. ???? ???? ??? ???? ?? ???? ???? ???? ?? ??? ??? ??? ??????. <… .  

<!--index.wxml-->
<view class="container">//視圖容器
 <view bindtap="bindViewTap" class="userinfo">//bindtap為容器綁定點(diǎn)擊觸摸事件,在觸摸離開時(shí)觸發(fā)bindViewTap事件處理函數(shù),bindViewTap通過index.js page()設(shè)置添加
  <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>//大雙括號(hào)的變量來自于index.js的data對(duì)象解析成對(duì)應(yīng)的值,而且是實(shí)時(shí)的
  <text class="userinfo-nickname">{{userInfo.nickName}}</text>
 </view>
 <view class="usermotto">
  <text class="user-motto">{{motto}}</text>
 </view>
</view>

 index.js, ???? react? ?? ??, ?? ??? ?? ??? ??? ???. page() ???? ?????. ???? ?? ???, ?? ?? ??, ??? ?? ?? ?? ???? OBJECT ????? ?????.

var app = getApp() // 獲取入口文件app的應(yīng)用實(shí)例
Page({
 data: {
  motto: &#39;Hello World&#39;,
  userInfo: {}
 },
 //自定義事件處理函數(shù),點(diǎn)擊.userinfo的容易觸發(fā)此函數(shù)
 bindViewTap: function() {
  wx.navigateTo({//全局對(duì)象wx的跳轉(zhuǎn)頁(yè)面方法
   url: &#39;../logs/logs&#39;
  })
 },
 onLoad: function () {//發(fā)生頁(yè)面加載時(shí),自動(dòng)觸發(fā)該生命周期函數(shù)
  console.log(&#39;onLoad&#39;)
  var that = this
  //調(diào)用應(yīng)用實(shí)例的方法獲取全局?jǐn)?shù)據(jù)
  app.getUserInfo(function(userInfo){
   //更新數(shù)據(jù),頁(yè)面自動(dòng)渲染
   that.setData({
    userInfo:userInfo
   })
  })
 }
})

index.wxss ??? ?? ???? ????? ?? app.wxss? ??? ???? ?????. <… .

logs.wxml ??

<!--logs.wxml-->
<view class="container log-list">
 <block wx:for="{{logs}}" wx:for-item="log">//block容器作用,無(wú)其他實(shí)際含義。wx:for作用:遍歷logs數(shù)組,遍歷多少次,block塊就會(huì)復(fù)制多少次,for-item等同于為<br>遍歷元素起一個(gè)變量名,方便引用。<br>
  <text class="log-item">{{index + 1}}. {{log}}</text>
 </block>
</view>

logs.js ??

//logs.js
var util = require(&#39;../../utils/util.js&#39;) //util.js相當(dāng)于一個(gè)函數(shù)庫(kù),我們可以在這個(gè)文件內(nèi)自定義擴(kuò)展和封裝一些常用的函數(shù)和方法
Page({
 data: {
  logs: []
 },
 onLoad: function () {
  this.setData({
   logs: (wx.getStorageSync(&#39;logs&#39;) || []).map(function (log) {//通過wx.getStorageSync獲取本地緩存的logs日志數(shù)據(jù)
    return util.formatTime(new Date(log))//日期格式化
   })
  })
 }
})

Logs.json ??

{
  "navigationBarTitleText": "查看啟動(dòng)日志"  //當(dāng)前頁(yè)面配置文件,設(shè)置window當(dāng)前頁(yè)面頂部導(dǎo)航欄標(biāo)題等相關(guān)內(nèi)容
}

? ??? ?? ???? ??? ??? ????. ? ???? ??? ??? ?????!

?? ?? ???? ????? ????? ?? ??? ??? ?? ?? ?? ?? ? ???? PHP ??? ????? ??????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???