欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

超簡(jiǎn)單的微信小程序輪播圖

Tips:微信小程序可以在HbuilderX用HTML標(biāo)簽(如Ddiv、span等)寫(xiě)前端代碼,也可以用微信小程序語(yǔ)法寫(xiě)(view、swiper標(biāo)簽),然后npm run dev編譯后,在微信開(kāi)發(fā)者工具里面導(dǎo)入該項(xiàng)目,就可以調(diào)試項(xiàng)目,查看效果。

成都創(chuàng)新互聯(lián)公司是一家專(zhuān)業(yè)從事成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)的網(wǎng)絡(luò)公司。作為專(zhuān)業(yè)網(wǎng)站建設(shè)公司,成都創(chuàng)新互聯(lián)公司依托的技術(shù)實(shí)力、以及多年的網(wǎng)站運(yùn)營(yíng)經(jīng)驗(yàn),為您提供專(zhuān)業(yè)的成都網(wǎng)站建設(shè)、成都全網(wǎng)營(yíng)銷(xiāo)推廣及網(wǎng)站設(shè)計(jì)開(kāi)發(fā)服務(wù)!

效果圖:

超簡(jiǎn)單的微信小程序輪播圖

微信小程序?qū)崿F(xiàn)輪播圖,本例是在*.wpy頁(yè)面開(kāi)發(fā)(該頁(yè)面的temlate內(nèi)容對(duì)應(yīng)小程序的wxml,style樣式對(duì)應(yīng)小程序的wxss,script對(duì)應(yīng)小程序的js文件,config對(duì)應(yīng)小程序的json文件)

<style type="less" scoped="scoped">
  .swiper image {
   width: 100%;
   height: auto;
 }
 
  .swiper-image {
   height: 100%;
   width: 100%;
  }
 
  .slide-image {
   height: 100%;
   width: 100%;
   display: block;
  }
</style>
<template>
   <view class="swiper">
    <swiper indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}" duration="{{duration}}" interval="{{interval}}" indicator-active-color="#007aff" bindchange="bindchange" circular="{{circular}}"
      >
      <block wx:for="{{GoodsDatas.imgshow}}" wx:for-key="{{index}}" wx:for-item="image">
        <swiper-item>
          <image src="{{image.img}}" data-id="{{index}}" class="slide-image" mode="widthFix" bindload="imageLoad" />
        </swiper-item>
       </block>
     </swiper>
   </view>
</template>
<script>
 import wepy from '@wepy/core'
 wepy.page({
  data: {
   circular: true,
   //是否顯示畫(huà)板指示點(diǎn),根據(jù)圖片數(shù)量自動(dòng)生成多少個(gè)圓點(diǎn)
   indicatorDots: true,
   //選中點(diǎn)的顏色
   //是否豎直
   vertical: false,
   //是否自動(dòng)切換
   autoplay: true,
   //自動(dòng)切換的間隔
   interval: 3000,
   //滑動(dòng)動(dòng)畫(huà)時(shí)長(zhǎng)毫秒
   duration: 1000,
   //所有圖片的高度
   imgheights: [],
   //圖片寬度
   imgwidth: 320,
   //默認(rèn)
   current: 0
  },
  imageLoad: function(e) { //獲取圖片真實(shí)寬度
   var imgwidth = e.detail.width,
    imgheight = e.detail.height,
    //寬高比
    ratio = imgwidth / imgheight;
   console.log(imgwidth, imgheight)
   //計(jì)算的高度值
   var viewHeight = 750 / ratio;
   var imgheight = viewHeight;
   var imgheights = this.data.imgheights;
   //把每一張圖片的對(duì)應(yīng)的高度記錄到數(shù)組里
   imgheights[e.target.dataset.id] = imgheight;
   this.setData({
    imgheights: imgheights
   })
  },
  bindchange: function(e) {
   // console.log(e.detail.current)
   this.setData({
    current: e.detail.current
   })
  }
 })
</script>

將代碼粘過(guò)去之后,只需要修改循環(huán)對(duì)象為圖片數(shù)據(jù)就可以了。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

本文名稱(chēng):超簡(jiǎn)單的微信小程序輪播圖
分享路徑:http://chinadenli.net/article26/giiijg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、微信公眾號(hào)域名注冊(cè)、網(wǎng)站設(shè)計(jì)、網(wǎng)站策劃、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開(kāi)發(fā)公司