Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Cloud development gadget components


May 22, 2021 Mini Program Cloud Development Study Guide


Table of contents


We've been in touch with the components that represent text, the components that represent images, the components that represent view containers, the components that represent links, the components that represent links, which greatly enrich the structure layout and element types of small programs, and we'll cover some of the components next.

The property of the component

We've already approached some of the components in a hands-on way, and this time we'll look back at some of the basic concepts, which are the properties of the components.

Public properties are properties that all components of a small program have, such as id, class, style, and so on, while the values of different properties are data, and there are data types.

Technical documentation: Small program components

You can open the technical documentation above to get a quick look at what are the common properties of the component, what are the types of properties, the types of data types and value descriptions. I n addition to common properties, different components have their own unique properties. C heck the technical documentation and you can understand how much, don't force understanding and memory. In real development, many properties we don't

Small tasks: Use the technical documentation to find out what are the private attributes of the components, the components, and the components.

Being good at accessing technical documents is a very important ability for programmers in any direction, just like learning an English dictionary. I n actual development, a new technical direction you can rely on no longer has the role of a teacher, because no one has an obligation to teach you. Technical documentation and search capabilities are your most trusted support.

The rost effect

Many apps and gadgets have a picture carncast at the top of the page, and the applet has a dedicated carncast component, whisperer. To learn more about the wheeling components of the swiftr, of course, it is possible to read the official technical documentation

Technical documentation: Wheeling components swift

Using the developer tool, enter the following code in home.wxml:

  1. <view class="home-top">
  2. <view class="home-swiper">
  3. <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="{{indicatorColor}}" indicator-active-color="{{activecolor}}">
  4. <block wx:for="{{imgUrls}}" wx:key="*this" >
  5. <swiper-item>
  6. <image src="{{item}}" style="width:100%;height:200px" class="slide-image" mode="widthFix" />
  7. </swiper-item>
  8. </block>
  9. </swiper>
  10. </view>
  11. </view>

Then add .js data to the data in the home store:

  1. imgUrls: [
  2. 'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640',
  3. 'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640',
  4. 'https://images.unsplash.com/photo-1551446591-142875a901a1?w=640'
  5. ],
  6. interval: 5000,
  7. duration: 1000,
  8. indicatorDots: true,
  9. indicatorColor: "#ffffff",
  10. activecolor:"#2971f6",
  11. autoplay: true,

To form a completecarnation, in addition to configuring pictures of the same size specifications, you can also configure panel indicator points, animation effects, whether to play automatically, and so on. The carnation components with their own unique properties, we can do more configuration, combined with the developer tools of the actual effect, to understand the technical documentation of these properties and the value of the properties.

Audio component

The audio component is an audio component, and we enter the following code in the home.wxml file:

  1. <audio src="{{musicinfo.src}}" poster="{{musicinfo.poster}}" name="{{musicinfo.name}}" author="{{musicinfo.author}}" controls></audio>

Then add .js data to the data in the home store:

  1. musicinfo: {
  2. poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
  3. name: '此时此刻',
  4. author: '许巍',
  5. src: 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46',
  6. },

Technical documentation: Audio component technical documentation

  • src: The resource address to play the audio
  • poster: The picture resource address of the audio cover page on the default control
  • name: The audio name on the default control
  • author: The author's name on the default control

Perhaps because the audio component uses very low scenes and frequencies, the audio component will be discarded later and the API of the small program will be required to create music playback.

Video component

The video component is used to represent video, and we enter the following code in the home.wxml file:

  1. <video id="daxueVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" rel="external nofollow" rel="external nofollow" autoplay loop muted initial-time="100" controls event-model="bubble">
  2. </video>

Technical documentation: Video component technical documentation

You can combine the actual effects and technical documentation to understand the following properties, the above case autoplay or a property to delete to see the specific effects, to deepen their understanding of component properties.

  • autoplay: Whether to play automatically
  • Loop: Whether to loop
  • Muted: Whether to mute playback
  • inital-time: Specify the initial playback location of the video in seconds
  • Controls: Whether the default playback control is displayed

Cover effect

We can also overlay the view, picture components on the map map or video video video components. For example, if we want to display the title of the video in the upper-left corner of the video and the logo of the merchant in the upper-right corner, we can use the cover effect.

  1. <video id="daxueVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" rel="external nofollow" rel="external nofollow" controls event-model="bubble">
  2. <view class="covertext">腾讯大学:腾讯特色学习交流平台</view>
  3. <image class="coverimg" src="https://imgcache.qq.com/open_proj/proj_qcloud_v2/gateway/portal/css/img/nav/logo-bg-color.svg" rel="external nofollow" ></image>
  4. </video>

Enter the following code in the wxss file;

  1. .covertext{
  2. width: 500rpx;
  3. color: white;
  4. font-size: 12px;
  5. position: absolute;
  6. top:20rpx;
  7. left:10rpx;
  8. }
  9. .coverimg{
  10. width:100rpx;height:23rpx;
  11. position: absolute;
  12. right:10rpx;
  13. top:10rpx;
  14. }

The map component

To mark a place on a map, we first need to know the latitude and longitude of that location, and this time we need to use the coordinate picker tool.

Latitude and longitude acquisition: Tencent map coordinate picker

In the search box we can search for "Shenzhen Tencent Building" with a latitude of 22.540503 and a longitude of 113.934528.

Using the developer tool, enter the following code in home.wxml:

  1. <map
  2. id="myMap"
  3. style="width: 100%; height: 300px;"
  4. latitude="{{latitude}}"
  5. longitude="{{longitude}}"
  6. markers="{{markers}}"
  7. covers="{{covers}}"
  8. show-location
  9. ></map>

Then add .js code to the data of the home page:

  1. latitude: 22.540503,
  2. longitude: 113.934528,
  3. markers: [{
  4. id: 1,
  5. latitude: 22.540503,
  6. longitude: 113.934528,
  7. title: '深圳腾讯大厦'
  8. }],

In the developer tool simulator, we can see the map of Tencent Building, click on the marker tag, you can see the custom name of Shenzhen Tencent Building. Click on the preview of the developer's tool and use the QR code generated by the mobile WeChat scan, which is slightly different from the map and simulator in the mobile weChat.

Technical documentation: Map component technical documentation

Mark multiple points on the map

Note from the technical documentation we can see where the marks marks are used to display the markers on the map, its data type is array array, and we also see the case above where its data is wrapped in parentheses. T hat is, we can mark multiple points on the map. Add a few more coordinates to markers:

  1. markers: [
  2. {
  3. id: 1,
  4. latitude: 22.540503,
  5. longitude: 113.934528,
  6. title: '深圳腾讯大厦'
  7. },
  8. {
  9. id: 2,
  10. latitude: 22.540576,
  11. longitude: 113.933790,
  12. title: '万利达科技大厦'
  13. },
  14. {
  15. id: 3,
  16. latitude: 22.522807,
  17. longitude: 113.935338,
  18. title: '深圳腾讯滨海大厦'
  19. },
  20. {
  21. id: 4,
  22. latitude: 22.547400,
  23. longitude: 113.944370,
  24. title: '腾讯C2'
  25. },
  26. ],

It marks Tencent's four locations in Shenzhen, where you can preview the actual effect on your phone.

Maps are a very complex component, in addition to marker, there are the following properties, you can study according to the actual needs of their own.

  • callout: click marker bubble callout, as well as bubble on the label, you can rich click on the map mark pop up rich information introduction;
  • Circle: Displays a circle on a map, such as a visualization of a circle of several kilometers, or a weight size on a map
  • polygon: Specifies a series of coordinate points to generate closed polygons based on points coordinate data, such as ringing the actual range
  • Polyline: Specify a series of coordinate points, from the first item of the array to the last item, such as the route of the run