网友真实露脸自拍10p,成人国产精品秘?久久久按摩,国产精品久久久久久无码不卡,成人免费区一区二区三区

小程序模板網

微信小程序開發實戰&電影小程序之(2)——閱讀頁面輪播圖-新聞列表頁面構建

發布時間:2018-04-23 11:42 所屬欄目:小程序開發教程

今天打開微信官方文檔發現輪播圖組件更新了兩個功能,但是目前暫未啟用,估計過幾天就能使用了。


屬性名 類型 默認值 說明
indicator-color Color rgba(0,0,0,.3) 指示點顏色 (這個屬性目前暫未啟用)
indicator-active-color Color #000000 當前選中的指示點顏色 (這個屬性目前暫未啟用)

最終的效果圖:

這里寫圖片描述


代碼部分:

下面我們來繼續研究代碼部分: 
wxml部分:

<view>
  <swiper indicator-dots="true" autoplay="true" interval="2000">
  <block wx:for="{{imgUrls}}">
    <swiper-item>
      <image src="{{item}}"></image>
    </swiper-item>
    </block>
  </swiper>
</view>
  •  

注意:swiper-item僅可放置在swiper組件中,寬高自動設置為100%。


js部分:

  data:{
    imgUrls: [
      '/images/wx.png',
      '/images/vr.png',
      '/images/iqiyi.png'
    ]
  },

js文件中定義了一個數組,里面存放圖片的路徑


wxss代碼:

swiper,swiper image {
  width: 100%;
  height: 500rpx;
}
  •  

注意:輪播圖組件的寬高樣式需要設置在swiper標簽上,官方文檔中沒有說明,只能一個一個試,最后的結論是必須定義在swiper標簽。

1、效果圖預覽

這里寫圖片描述


2、準備工作

在拿到效果圖后不要先急著去寫代碼,而是要去分析一下頁面的整體結構,用什么方式定位和布局。小程序里建議使用flex布局,因為小程序對flex的支持是很好的。

上一篇博客中完成了輪播圖部分,接下來繼續完成下面的新聞列表部分

3、wxml部分

新聞列表部分整體使用flex縱向布局比較合適,  先把頁面內的元素標簽和類名寫好。

    <view class="post-container">
      <view class="post-author-date">
        <image class="post-author" src="{{item.avatar}}"></image>
        <text class="post-date">{{item.date}}</text>
      </view>
      <text class="post-title">{{item.title}}</text>
      <image class="post-image" src="{{item.imgSrc}}"></image>
      <text class="post-content">{{item.content}}</text>
      <view class="post-like">
        <image class="post-like-image" src="{{item.view_img}}"></image>
        <text class="post-like-font">{{item.reading}}</text>
        <image class="post-like-image" src="{{item.collect_img}}"></image>
        <text class="post-like-font">{{item.collection}}</text>
      </view>
    </view>
  •  

4、wxss部分

.post-container{
  display: flex;
  flex-direction: 


易優小程序(企業版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.xiuhaier.com/wxmini/doc/course/23920.html 復制鏈接 如需定制請聯系易優客服咨詢:800182392 點擊咨詢
QQ在線咨詢
AI智能客服 ×