欧美日韩中文一区二区,亚洲天堂av在线,亚洲最大成人免费视频,欧美最新精品

微信小程序開發(fā)組件和API接口使用教程

微信小程序開發(fā)者工具為開發(fā)者提供了組件和API接口,下面就和大家詳細介紹一下微信小程序開發(fā)組件和API接口使用教程,希望對大家有所幫助!

(一)、什么是微信小程序開發(fā)組件和API接口

微信小程序開發(fā)組件主要是完成小程序視圖部分,包括文字、圖片等操作。

微信小程序開發(fā)組件

API接口主要是完成小程序邏輯功能部分,包括網(wǎng)絡請求、數(shù)據(jù)庫存儲、微信支付等功能。

API接口

(二)、API接口使用教程

下面就以豆瓣為例,帶大家分析一下API接口使用教程!

1.底部導航:可以通過設置tabBar屬性來實現(xiàn),可以參考官網(wǎng)文檔https://mp.weixin.qq.com/debug/wxadoc/dev/framework/config.html

API接口使用教程

示例代碼如下:

“tabBar”: {

“backgroundColor”: “#363636”,

“color”:”#666″,

“selectedColor”:”#fff”,

“list”: [{

“pagePath”: “pages/index/index”,

“text”: “正在熱映”,

“iconPath”: “res/images/film.png”,

“selectedIconPath”: “res/images/film.png”

},

{

“pagePath”: “pages/recommend/recommend”,

“text”: “熱門推薦”,

“iconPath”: “res/images/hot.png”,

“selectedIconPath”: “res/images/hot.png”

},

{

“pagePath”: “pages/search/search”,

“text”: “影片搜索”,

“iconPath”: “res/images/search.png”,

“selectedIconPath”: “res/images/search.png”

}

]

}

2.頂部banner圖

頂部banner圖可以通過swiper組件來實現(xiàn),具體操作:組件-視圖容器-swiper。復制官方實例,操作之后,看看效果圖,然后進行修改調(diào)整,代碼示例:

<swiper indicator-dots=”{{indicatorDots}}”

autoplay=”{{autoplay}}” interval=”{{interval}}” duration=”{{duration}}”>

Page({

data: {

imgUrls: [ ? ? ?‘http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg’, ? ? ?‘http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg’, ? ? ?‘http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg’

],

indicatorDots: false,

autoplay: false,

interval: 5000,

duration: 1000

}

})

3.展示部分

展示部分我們會用到視圖容器view、媒體組件image、基礎內(nèi)容組件text等。

4.網(wǎng)絡請求

網(wǎng)絡請求可以通過js來實現(xiàn),具體操作:API-網(wǎng)絡-網(wǎng)絡請求、示例代碼:

var url=”https://api.douban.com/v2/movie/in_theaters”;

wx.request({

url: url,

method: ‘GET’, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT ? ? ?header: {

‘Content-Type’:’application/json’//返回json格式,必須要加

}, // 設置請求的 header ? ? ?success: function(res){

console.log(res.data.subjects);

that.setData({

movies:res.data.subjects

});

}

})

5. 數(shù)據(jù)交互

數(shù)據(jù)交互找到數(shù)據(jù),綁定文檔,然后再提交給邏輯層,再將邏輯層傳到視圖層。

具體操作流程:框架—視圖層—WXML(http://www.573732.com/2294.html)—事件,如圖所示:

{{ message }}

Page({

data: {

message: ‘Hello MINA!’

}

})

Click me!

Page({

tapName: function(event) {

console.log(event)

}

})

以上就是微信小程序開發(fā)組件和API接口使用教程,大家可以作為參考,也可以嘗試操作一下。


聲明:本站部分文章來源于互聯(lián)網(wǎng),如有侵犯作者著作權,請及時與我們聯(lián)系。

木魚小鋪小程序

為您推薦

主站蜘蛛池模板: 曲靖市| 台南县| 凤冈县| 万源市| 阳原县| 大城县| 禹城市| 万宁市| 罗甸县| 民县| 乌拉特中旗| 富川| 贵溪市| 故城县| 蒙阴县| 云龙县| 安吉县| 乃东县| 集安市| 紫金县| 左云县| 金山区| 永川市| 刚察县| 开化县| 隆尧县| 怀宁县| 民权县| 耒阳市| 龙山县| 星子县| 嘉荫县| 吉安县| 牙克石市| 泗洪县| 阜康市| 枝江市| 呼伦贝尔市| 甘南县| 临潭县| 上蔡县|