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

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

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

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

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

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

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

API接口

(二)、API接口使用教程

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

1.底部導航:可以通過設置tabBar屬性來實現(xiàn)。

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。復制官方實例,操作之后,看看效果圖,然后進行修改調整,代碼示例:

<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、基礎內容組件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)系。

木魚小鋪小程序

為您推薦

主站蜘蛛池模板: 古田县| 麦盖提县| 巴青县| 广西| 吉水县| 宁武县| 济源市| 贵南县| 南汇区| 南和县| 无锡市| 盐边县| 赤壁市| 鹿邑县| 怀柔区| 区。| 广饶县| 天津市| 瓦房店市| 清镇市| 山西省| 玉龙| 信丰县| 古浪县| 界首市| 惠来县| 巴南区| 肃北| 绥德县| 夏河县| 金华市| 东安县| 隆回县| 天水市| 耒阳市| 郸城县| 综艺| 龙胜| 合肥市| 柳林县| 如东县|