微信小程序-样式和组件(3)navigator/scroll-view组件

一.navigator组件

open-type属性介绍:
navigator组件实现小程序的跳转,如从商品图片跳转到详情页面。
navigator:保留当前页面,跳转到应用到某一个页面,但不能跳转到tabbar页面
redirect:关闭当前页面,跳转到应用到某一个页面,但不能跳转到tabbar页面
switch Tab:跳转到tabbar页面,并关闭其他非tabbar页面
reLaunch:关闭所有页面,打开到应用的某个页面
navigateBack:关闭当前页面,返回上一个页面或几个页面

  <navigator url="/pages/list/list" open-type="navigate">
    <image src="../../assets/nav1.png" />
    <text>鲜花玫瑰</text>
  </navigator>

url属性介绍:
传参使用&将参数进行拼接

/pages/list/list?id=1&name=test

二.scroll-view组件

实现小程序横向和纵向的滚动
横向滚动代码:
在.wxml文件里面创建scroll-view组件,并在里面放着三个view
scroll-x属性的值为ture,也可以只写属性scroll-x,默认值为true

<scroll-view class = "scroll-x" scroll-x="true">
<view>1</view>
<view>2</view>
<view>3</view>
</scroll-view>

在.scss文件里面渲染scroll-view,通过class选择器

.scroll-x{
  width: 100%;
  white-space: nowrap;
  background-color:skyblue;
  view{
    display: inline-flex;
    width: 300rpx;
    height: 80rpx;
    &:first-child{
      background:lightcoral;
    }
    &:last-child{
      background-color: lightgreen;
    }
  }

}

效果图:
在这里插入图片描述

同样纵向滚动的代码如下:

<scroll-view class = "scroll-y" scroll-y="true">
<view>1</view>
<view>2</view>
<view>3</view>
</scroll-view>
.scroll-y{
  height: 400rpx;
  background-color: skyblue;
  margin-top: 10rpx;
  view{
    height: 400rpx;
    &:first-child{
      background:lightcoral;
    }
    &:last-child{
      background-color: lightgreen;
    }
  }
}          

效果图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值