<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # 小程序 ## 小程序簡介 ### 文檔與結構 小程序結構圖 ![](https://box.kancloud.cn/3a857fa1c0412f895f4116e84b0b6a91_1160x906.png) **app.json文件小程序設置全局配置 ,包括頁面路徑、窗口、選項卡,以及網絡超時等 app.js文件中App()來注冊一個小程序 提供了生命周期方法 app.wxss小程序應用的樣式文件** 小程序文件結構圖 ### 知識儲備 * 首先得有一定的網站開發基礎(html css js) * 因為不能像做網站那樣用js中的window,document方法,所以要多看官網給的api文檔 * 全新的一個模式,好多東西微信自己都還沒定下來,所以就是要多看多練。 * 由于大小限制,所以不適合做大型開發。 ## 小程序常用的API和邏輯綁定方法 **wx.request https網絡請求** ~~~ wx.request({ url: 'test.php', //僅為示例,并非真實的接口地址 method:"GET", data: { x: '' , y: '' }, header: { 'content-type': 'application/json' }, success: function(res) { console.log(res.data) } }) ~~~ **本地緩存**<br> **通過key的形式添加緩存setStorage (異步接口)** ~~~ wx.setStorage({ key:"key" data:"value" }) ~~~ **通過key的形式獲取緩存getStorage (異步接口)** ~~~ wx.getStorage({ key: 'key', success: function(res) { console.log(res.data) } }) ~~~ **從本地緩存中異步移除指定 key** ~~~ wx.removeStorage({ key: 'key', success: function(res) { console.log(res.data) } }) ~~~ **清理本地數據緩存** ~~~ wx.clearStorage() 顯示、隱藏消息提示框 wx.showToast({ title: '加載中', icon: 'loading', duration: 10000 }) setTimeout(function(){ wx.hideToast() },2000) ~~~ **動態設置當前頁面的標題** ~~~ wx.setNavigationBarTitle({ title: '當前頁面' }) ~~~ **導航** **保留當前頁面,跳轉到應用內的某個頁面** ~~~ wx.navigateTo({ url: 'test?id=1' }) ~~~ **關閉當前頁面,跳轉到應用內的某個頁面** ~~~ wx.redirectTo({ url: 'test?id=1' }) ~~~ **獲取用戶信息,需要先調用 wx.login 接口** ~~~ wx.getUserInfo({ success: function(res) { var userInfo = res.userInfo var nickName = userInfo.nickName var avatarUrl = userInfo.avatarUrl var gender = userInfo.gender //性別 0:未知、1:男、2:女 var province = userInfo.province var city = userInfo.city var country = userInfo.country } } ) ~~~ **設備 獲取網絡類型** ~~~ wx.getNetworkType({ success: function(res) { var networkType = res.networkType // 返回網絡類型2g,3g,4g,wifi } }) ~~~ **獲取系統信息(異步接口)** ~~~ wx.getSystemInfo({ success: function(res) { console.log(res.model) console.log(res.pixelRatio) console.log(res.windowWidth) console.log(res.windowHeight) console.log(res.language) console.log(res.version) } }) ~~~ **撥打電話** ~~~ wx.makePhoneCall({ phoneNumber: '1340000' //僅為示例,并非真實的電話號碼 }) ~~~ **獲取當前的地理位置、速度** ~~~ wx.getLocation({ type: 'wgs84', success: function(res) { var latitude = res.latitude var longitude = res.longitude var speed = res.speed var accuracy = res.accuracy } }) ~~~ ## 隨手記 > 隨手記錄:const類似var 傳遞參數 在data{}中聲明參數,在onLoad里面去傳遞參數(賦值) 例: ~~~ data: { pageNum:1 } const _this=this _this.setData({ pageNum:++_this.data.pageNum }) ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看