Introduction:
For front-end engineers, banner diagrams are an essential part of front-end development. But how to implement banner graphics for small programs that lack DOM? Just like other frameworks encapsulate different banner diagram methods, mini programs also encapsulate banner methods. Let’s take a look at the specific implementation methods.
(Learning video sharing: Introduction to Programming)
1: Preparation work
I will use two pictures, as shown below:
1.jpg
2.jpg
Two: Write xsml code (i.e. html)
If we use the
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="true"> <block wx:for="{{arr}}"> <swiper-item> <image src="{{item}}" class="slide-image" width="355" height="150"/> </swiper-item> </block> </swiper>
Page({ /** * 页面的初始数据 */ data: { mode:"scaleToFill", arr:[], indicatorDots: true, autoplay: true, interval: 2000, duration: 1000, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var array = this.data.arr for (let i = 1; i < 3; i++) { array.push("img/" + i + ".jpg") } this.setData({ arr: array}) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, })
Mini Program Development Tutorial
The above is the detailed content of Use a small program to create a banner image. For more information, please follow other related articles on the PHP Chinese website!