android微信头条小程序容器,微信小程序的视图容器-view

微信小程序的视图容器主要包括是是三个,分别是

1.view

2.scrollView

3.swiper

一、view

view就是视图的意思,类似于html中标签

我们先来写一个简单的view

在.wxml中写一个view

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

在对应的.wxss文件写headerView的样式

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

运行结果:在页面显示一个高度为300rpx的view

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

这里我们需要指出一点的是微信小程序的尺寸单位rpx

rpx单位是微信小程序中css的尺寸单位,rpx可以根据屏幕宽度进行自适应。规定屏幕宽为750rpx。如在 iPhone6 上,屏幕宽度为375px,共有750个物理像素,则750rpx = 375px = 750物理像素,1rpx = 0.5px = 1物理像素。

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

当然微信小程序也支持rem尺寸单位,rem和rpx的换算关系:rem: 规定屏幕宽度为20rem;1rem = (750/20)rpx 。

多视图容器

.wxml文件

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

.wxss文件

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

视图view的事件绑定

为searchView视图容器绑定点击事件bindtap。

.wxml文件

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

在对应的.js文件中,触发该事件

d92e9c9974a3?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation

点击comman+s运行之后,在控制台输出

触发事件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值