全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

微信小程序 UI与容器组件总结

微信小程序 UI与容器组件总结

    1.总结与概述

    2.容器组件

            2.1 组件容器(view)

            2.2 可滚动视图容器(scroll-view)

            2.3 滑块视图容器(swiper)

1.总结与概述

1.1 UI组件总结图

 1.2 概述

        小程序的UI组件也就是定义用户界面的一系列标签,类似于html标签。一个完整用户响应过程:事件触发——>UI组件接收到事件——>触发js函数响应事件——>更新UI

 2.容器组件

2.1 容器组件(view)

    (1)总结


    (2)例子

        效果图


        page.wxml

<view>
 <text class="row-view-title">水平布局:</text>
 <view class="flex-wrp-row">
  <view class="flex-item-red" hover="true" hover-class="hover-style"><text class="color-text">red</text></view>
  <view class="flex-item-green" hover="true" hover-class="hover-style"><text class="color-text">green</text></view>
  <view class="flex-item-blue" hover="true" hover-class="hover-style"><text class="color-text">blue</text></view>
 </view>
</view>
<view>
 <text class="column-view-title">垂直布局:</text>
 <view class="flex-wrp-column" >
  <view class="flex-item-red" hover="true" hover-class="hover-style"><text class="color-text" >red</text></view>
  <view class="flex-item-green" hover="true" hover-class="hover-style"><text class="color-text">green</text></view>
  <view class="flex-item-blue" hover="true" hover-class="hover-style"><text class="color-text">blue</text></view>
 </view>
</view>

        page.wxss

.flex-item-red{
 background-color: red;
 height: 200rpx;
 width: 200rpx;
 text-align: center;
 line-height: 200rpx;
}
.flex-item-green{
 background-color: green;
 height: 200rpx;
 width: 200rpx;
 text-align: center;
 line-height: 200rpx
}
.flex-item-blue{
 background-color: blue;
 height: 200rpx;
 width: 200rpx;
 text-align: center; 
 line-height: 200rpx 
}
.flex-wrp-row{
 flex-direction: row;
 display: flex;
 margin-left: 10rpx;
 margin-top: 20rpx;
}
.flex-wrp-column{
 flex-direction: column;
 display: flex;
 margin-left: 10rpx;
  margin-top: 20rpx;
}
.color-text{
 color: snow;
 font-family: 'Times New Roman', Times, serif;
 font-weight: bold;
}
.hover-style{
 background-color: black;
}
.row-view-title,.column-view-title{
 margin-left: 20rpx;
 font-family: 'Times New Roman', Times, serif;
 font-weight: bold;
}
/*重要属性:
 display: flex; //与display:box;是类似,是flexbox的最新语法格式,有更好的适配效果
 flex-direction: column; //表示子布局垂直布局
 flex-direction: row; //表示子布局为水平布局
*/

 2.2 可滚动视图容器(scroll-view)

    (1) 总结


     (2) 例子

       效果图:


     page.wxml

<view>
<text>水平滚动布局</text>
</view>
<view class="x-view">
 <scroll-view class="scroll-view-x" scroll-x="true" bindscrolltoupper="scrollXToUpper" bindscrolltolower="scrollXToLower" bindscroll="scroll" scroll-left="0" scroll-into-view="{{green}}">
  <view id="green" class="x_green"></view>
  <view id="red" class="x_red"></view>
  <view id="yellow" class="x_yellow"></view>
  <view id="blue" class="x_blue"></view>
 </scroll-view>
</view>
<view>
<text>垂直滚动布局</text>
</view>
<view class="y-view">
 <scroll-view class="scroll-view-y" scroll-y="true" bindscrolltoupper="scrollYToUpper" bindscrolltolower="scrollYToLower" bindscroll="scroll" scroll-top="0" scroll-into-view="{{green}}">
  <view id="green" class="y_green"></view>
  <view id="red" class="y_red"></view>
  <view id="yellow" class="y_yellow"></view>
  <view id="blue" class="y_blue"></view>
 </scroll-view>
</view>

    page.wxss

.x_green{
 background-color: green;
 width: 500rpx;
 height: 300rpx;
 display: inline-flex;
}
.x_red{
 background-color: red;
 width: 500rpx;
 height: 300rpx;
 display: inline-flex;
 
}
.x_blue{
 background-color: blue;
 width: 500rpx;
 height: 300rpx;
 display: inline-flex; 
}
.x_yellow{
 background-color: yellow;
 width: 500rpx;
 height: 300rpx; 
 display: inline-flex; 
}
.y_green{
 background-color: green;
 width: 100%;
 height: 300rpx;
}
.y_red{
 background-color: red;
 width: 100%;
 height: 300rpx;
}
.y_yellow{
 background-color: yellow;
 width: 100%;
 height: 300rpx;
}
.y_blue{
 background-color: blue;
 width: 100%;
 height: 300rpx;
}
.scroll-view-x{
 display: flex;
 white-space: nowrap;
 width: 100%;
 margin-bottom: 20px;
 margin-top: 10px; 
 height: 300rpx; 
}
.scroll-view-y{
 height: 400rpx;
}
/*重要属性:
 white-space: nowrap;//设置内部元素不换行显示,与display: inline-flex;属性联合使用才会有水平布局的效果
*/

    page.js

//index.js
//获取应用实例
var app = getApp()
//var color_index=['green','red','yellow','blue'];
Page({
 data:{
 toview:'red',
 },
/*滑动到左边触发*/
scrollXToUpper:function(){
 console.log('scrollXToUpper')
},
/*滑动到右边触发 */
scrollXToLower:function(){
 console.log('scrollXToLower')
},
/*滑动到顶部触发*/
scrollYToUpper:function(){
 console.log('scrollYToUpper')
},
/*滑动到左边触发 */
scrollYToLower:function(){
 console.log('scrollYToLower')
},
/*滑动触发 */
scroll:function(){
 console.log("scroll")
},
onLoad: function () {
 console.log('onLoad')
 var that = this
 },
})

2.3 滑块视图容器(swiper)

 (1)总结


(2)例子

    效果图:


     page.wxml

<swiper data-current="0" current="0" bindchange="itemChangeFunc" circular="true" indicator-dots="{{indicatorDots}}"
 autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
 <block wx:for="{{imgUrls}}" wx:key="swiperkeys">
  <swiper-item>
  <image src="{{item}}" class="slide-image" width="355" height="150"/>
  </swiper-item>
 </block>
</swiper>

  page.js

//game.js
Page({
 data: {
 imgUrls: [
  '/image/wechat.png',
  'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
  'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
  'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
 ],
 indicatorDots: true,
 autoplay: true,
 interval: 3000,
 duration: 1000,
 current:1,
 },
 
 durationChange: function(e) {
 this.setData({
  duration: e.detail.value
 })
 },
 durationChange: function(e) {
 this.setData({
  duration: e.detail.value
 })
 },
itemChangeFunc:function(e){
 // console.log(e.target.dataset.current)
 
 console.log(e.detail)
}
})

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


# 微信小程序  # UI与容器组件  # 小程序  # UI与容器组件详解  # 微信小程序 支付功能开发错误总结  # 微信小程序 常用工具类详解及实例  # 微信小程序 基础知识css样式media标签  # 微信小程序 http请求封装详解及实例代码  # 微信小程序 弹幕功能简单实例  # 微信小程序 详解页面跳转与返回并回传数据  # 微信小程序 this和that详解及简单实例  # 微信小程序 基础组件与导航组件详细介绍  # 微信小程序-获得用户输入内容  # 滑块  # 会有  # 希望能  # 谢谢大家  # 类似于  # 换行  # 应用实例  # 素不  # display  # left  # margin  # direction  # height  # background  # column  # wxss  # center  # line  # align  # rpx 


相关文章: 网页设计与网站制作内容,怎样注册网站?  定制建站模板如何实现SEO优化与智能系统配置?18字教程  C#怎么创建控制台应用 C# Console App项目创建方法  如何在阿里云虚拟机上搭建网站?步骤解析与避坑指南  太平洋网站制作公司,网络用语太平洋是什么意思?  制作网站的模板软件,网站怎么建设?  保定网站制作方案定制,保定招聘的渠道有哪些?找工作的人一般都去哪里看招聘信息?  建站主机功能解析:服务器选择与快速搭建指南  在线ppt制作网站有哪些,请推荐几个好的课件下载的网站?  制作营销网站公司,淘特是干什么用的?  如何在万网开始建站?分步指南解析  ,sp开头的版面叫什么?  实惠建站价格推荐:2025年高性价比自助建站套餐解析  娃派WAP自助建站:免费模板+移动优化,快速打造专业网站  定制建站方案优化指南:企业官网开发与建站费用解析  nginx修改上传文件大小限制的方法  如何选择网络建站服务器?高效建站必看指南  建站VPS推荐:2025年高性能服务器配置指南  打鱼网站制作软件,波克捕鱼官方号怎么注册?  如何制作公司的网站链接,公司想做一个网站,一般需要花多少钱?  建站之星上传入口如何快速找到?  建站之星导航配置指南:自助建站与SEO优化全解析  如何快速启动建站代理加盟业务?  如何高效生成建站之星成品网站源码?  建站之星体验版:智能建站系统+响应式设计,多端适配快速建站  开源网站制作软件,开源网站什么意思?  linux top下的 minerd 木马清除方法  建站之星手机一键生成:多端自适应+小程序开发快速建站指南  定制建站价位费用解析与套餐推荐全攻略  音响网站制作视频教程,隆霸音响官方网站?  如何正确下载安装西数主机建站助手?  济南专业网站制作公司,济南信息工程学校怎么样?  制作企业网站建设方案,怎样建设一个公司网站?  建站之星安装提示数据库无法连接如何解决?  IOS倒计时设置UIButton标题title的抖动问题  七夕网站制作视频,七夕大促活动怎么报名?  建站主机如何选?高性价比方案全解析  平台云上自助建站如何快速打造专业网站?  建站主机类型有哪些?如何正确选型  想学网站制作怎么学,建立一个网站要花费多少?  简单实现Android文件上传  我的世界制作壁纸网站下载,手机怎么换我的世界壁纸?  如何通过多用户协作模板快速搭建高效企业网站?  建站之星收费标准详解:套餐费用及年费价格表一览  建站主机选择指南:服务器配置与SEO优化实战技巧  济南企业网站制作公司,济南社保单位网上缴费步骤?  如何用已有域名快速搭建网站?  已有域名建站全流程解析:网站搭建步骤与建站工具选择  怎么用手机制作网站链接,dw怎么把手机适应页面变成网页?  建站ABC备案流程中有哪些关键注意事项? 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。