wxml 代码:

<!--pages/swipe/swipe.wxml-->
<view>
<swiper circular="true" indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block wx:for="{{imgUrls}}">
<swiper-item>
<image src="{{item}}" style="width: {{imageWidth}}px;" class="slide-image" model="aspectFit" />
</swiper-item>
</block>
</swiper> </view>
model="aspectFit"    mode 有 13 种模式,其中 4 种是缩放模式,9 种是裁剪模式。
缩放 aspectFit 保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来。 Js代码:
  data: {
imageWidth: wx.getSystemInfoSync().windowWidth,//图片宽度
indicatorDots:true,
autoplay:true,
interval: ,
duration: ,
imgUrls: [
'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640',
'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640',
'https://images.unsplash.com/photo-1551446591-142875a901a1?w=640'
],
},
wx.getSystemInfoSync().windowWidth   获取屏幕的窗口宽度


微信小程序swiper组件实现图片宽度自适应的更多相关文章

  1. 基于angular实现模拟微信小程序swiper组件

    这段时间的主业是完成一个家政类小程序,终于是过审核发布了.不得不说微信的这个小程序生态还是颇有想法的,抛开他现有的一些问题不说,其提供的组件系统乍一看还是蛮酷的.比如其提供的一个叫swiper的视图组 ...

  2. 微信小程序 swiper 组件坑

    swiper 组件高度被限制为150px了,所以内容无法撑开. 解决办法 给这组件重新设置个高度,然后在把里面的图片设置为自动适应容器大小.图片模式设置为 宽度不变 自动适应高度 <swiper ...

  3. 微信小程序--swiper组件

    <view class='swiper-container'> <swiper indicator-dots="true" autoplay=" ver ...

  4. 第五篇、微信小程序-swiper组件

    常用属性: 效果图: swiper.wxml添加代码: <swiper indicator-dots="{{indicatorDots}}" autoplay="{ ...

  5. 微信小程序_(组件)swiper轮播图

    微信小程序swiper轮播图组件官方文档 传送门 Learn: swiper组件 一.swiper组件 indicator-dots:是否显示面板指示点[默认值false] autoplay:是否自动 ...

  6. 微信小程序的组件总结

    本文介绍微信小程序的组件 视图容器 基础内容 表单组件 导航组件 媒体组件 视图容器 view 布局容器 <view hover-class='bg'>222</view> 可 ...

  7. 微信小程序--canvas画布实现图片的编辑

    技术:微信小程序   概述 上传图片,编辑图片大小,添加文字,改变文字颜色等 详细 代码下载:http://www.demodashi.com/demo/14789.html 概述 微信小程序--ca ...

  8. 【微信小程序】动态设置图片大小

    我们都知道微信小程序的组件image是用来显示图片的,它有一下几个属性:1.src              图片资源地址2.mode          图片裁剪.缩放的模式3.binderror   ...

  9. 微信小程序image组件binderror使用例子(对应html、js中的onerror)

    官方文档  binderror HandleEvent 当错误发生时,发布到 AppService 的事件名,事件对象event.detail = {errMsg: 'something wrong' ...

随机推荐

  1. JavaScript清空数组的三种方法

    [文章系摘自网络,看到有用记录在博客,同时共享给大家] 原链接:http://www.2cto.com/kf/201409/335383.html 方式1,splice   var ary = [1, ...

  2. 定时任务cron表达式解析

    cron表达式2种: Seconds Minutes Hours DayofMonth Month DayofWeek Year或 Seconds Minutes Hours DayofMonth M ...

  3. 定义一个JobService,开启本地服务和远程服务

    @SuppressWarnings(value = ["unchecked", "deprecation"])@RequiresApi(Build.VERSIO ...

  4. 简单Spring整合JdbcTemplate

    实体类: public class User implements Serializable{ private Integer id; private String username; private ...

  5. apache主要配置详解

    1. # Deny access to the entirety of your server's filesystem. You must # explicitly permit access to ...

  6. day32—CSS多列布局学习

    转行学开发,代码100天——2018-04-17 关于多列布局,前期已经梳理过,今天的培训课程学习中再次提及,趁此也做个总结和检验. 多列布局的介绍参考: day08—css布局解决方案之多列布局   ...

  7. day20—CSS中伪类:before与:after的应用:

    转行学开发,代码100天——2018-04-05 CSS中的两个伪类:before和:after适合应用与在元素的开始或者结尾处添加修饰性文字或外观,实现内容添加的同时并没有破坏HTML代码 语义.如 ...

  8. Mac003--Maven安装与环境变量配置

    Mac--Maven安装 一.应用brew安装maven及安装位置 打开终端,输入命令:brew install maven 参考博客:https://www.jianshu.com/p/230e0b ...

  9. tensorflow学习框架(炼数成金网络版学习记录)

    chapter1 #变量 import tensorflow as tf x = tf.Variable([1,2]) a = tf.constant([3,3]) #增加一个减法op sub = t ...

  10. for in 和for of的区别

    for in 和for of的区别:https://www.jianshu.com/p/c43f418d6bf0 1 遍历数组通常用for循环 ES5的话也可以使用forEach,ES5具有遍历数组功 ...