Detailed explanation of WeChat applet Image component example

高洛峰
Release: 2017-02-20 14:06:32
Original
2064 people have browsed it

This article mainly introduces relevant information about the detailed explanation of the Image component instance of the WeChat applet. Friends who need it can refer to it

微信小程序 Image组件实例详解

The image component is also a program. What is missing, it can be said that the image component can be seen everywhere in an app. Generally, there are two ways to load images. The first is network images and the second is local image resources, both of which are specified using the src attribute.

Key attributes:

微信小程序 Image组件实例详解

##Three scaling modes

微信小程序 Image组件实例详解

Nine cutting methods

微信小程序 Image组件实例详解

##wxml

<!--3中是缩放模式
 scaleToFill 不保持纵横比缩放图片,使图片的宽高完全拉伸至填满image元素
 aspectFit 保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来。
 aspectFill 保持纵横比缩放图片,只保证图片的短边能完全显示出来

-->
<view>aspectFit 保持纵横比缩放图片,只保证图片的短边能完全显示出来</view>
<image style="width: 100%; height:100%" mode="aspectFit" src="../../image/image.jpg"/>

<!--9种是裁剪模式
 top 不缩放图片,只显示图片的顶部区域
 bottom,同上
 left
 right
 top right
 top left
 bottom right
 bottom left
-->
<view>bottom 不缩放图片,只显示图片的底部区域</view>
<image style="width: 100%; height: 100%" mode="bottom" src="../../image/image.jpg"/>

<view>left 不缩放图片,只显示图片的左边区域</view>
<image style="width: 100%; height: 100%" mode="left" src="../../image/image.jpg"/>

<view>top right 不缩放图片,只显示图片的右上边区域</view>
<image style="width: 100%; height: 100%" mode="top right" src="../../image/image.jpg"/>
Copy after login

For more detailed examples of WeChat applet Image component, please pay attention to the PHP Chinese website for related articles!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!