<!--pages/find/find.wxml--> <view class="find-container"> <view class="find-main"> <view wx:for="{{list}}" wx:key="*this" data-pro="{{item}}" bindtap="jumpDetail" class="find-item"> <image src="{{item.pic}}" class="find-cover"></image> <text class="find-title">{{item.title}}</text> </view> </view> </view>
时间: 2023-08-05 21:10:50 浏览: 14
这是一个小程序的发现页模板,其中包含一个发现页的容器和一个主要内容区域。在内容区域中,通过`wx:for`循环遍历一个名为`list`的数组,数组中的每个元素被称为`item`。对于每个`item`,创建一个`find-item`的视图,并将`item`数据传递给该视图。在每个`find-item`视图中,有一个图片和一个标题,分别使用`item.pic`和`item.title`进行数据绑定。当点击`find-item`视图时,会触发名为`jumpDetail`的事件。你可以根据需要修改数组数据、图片路径、标题等内容。
相关问题
<!--index.wxml--> <view class="top-box"> <view>Hi</view> <view class="next-text">欢迎使用!</view> </view> <!-- 登录、注册 --> <view class="center-box"> <view class="nav"> <view class="left {{current==1?'select':''}}" bindtap="click" data-code="1"> <text>登录</text> </view> <view class="right {{current==0?'select':''}}" bindtap="click" > <text>注册</text> </view> </view> <!-- 登录 --> <view class="input-box" hidden="{{current==0}}"> <view class="wei-input"> <icon type="waiting" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入手机号/登录名"/> </view> <view class="wei-input"> <icon type="success" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入登录密码"/> </view> <view class="forget"> <text>忘记密码?</text> </view> </view> <!-- 注册 --> <view class="input-box" hidden="{{current==1}}"> <view class="wei-input"> <icon type="waiting" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入手机号"/> </view> <view class="wei-input"> <icon type="waiting" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入6位验证码"/> <text class="input-code" bindtap="getCode">{{codeText}}</text> </view> <view class="wei-input"> <icon type="success" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请输入密码"/> </view> <view class="wei-input"> <icon type="success" color="#44ADFB" size="16"></icon> <input class="input" auto-focus placeholder="请确认密码"/> </view> </view> <view class="sumbit-btn"> <button class="button" style="background-color: #33ccff;font-size: 30rpx;" type="primary">立即{{current==1?'登录':'注册'}}</button> </view> </view> <!-- 重影 --> <view class="shadow shadow-1"></view><view class="shadow shadow-2"></view> <!-- 说明 -->这段代码怎么实现注册页面和登陆页面的切换,如果不能,给出解决代码
这段代码是一个小程序的页面布局代码,其中使用了一个变量 current 来控制显示登录还是注册页面。具体的实现逻辑是,当 current 为 0 时显示注册页面,为 1 时显示登录页面。同时,通过绑定 click 事件来切换页面。
以下是完整的代码实现:
<!--index.wxml-->
<view class="top-box">
<view>Hi</view>
<view class="next-text">欢迎使用!</view>
</view>
<!-- 登录、注册 -->
<view class="center-box">
<view class="nav">
<view class="left {{current==1?'select':''}}" bindtap="click" data-code="1">
<text>登录</text>
</view>
<view class="right {{current==0?'select':''}}" bindtap="click" data-code="0">
<text>注册</text>
</view>
</view>
<!-- 登录 -->
<view class="input-box" hidden="{{current==0}}">
<view class="wei-input">
<icon type="waiting" color="#44ADFB" size="16"></icon>
<input class="input" auto-focus placeholder="请输入手机号/登录名"/>
</view>
<view class="wei-input">
<icon type="success" color="#44ADFB" size="16"></icon>
<input class="input" auto-focus placeholder="请输入登录密码"/>
</view>
<view class="forget">
<text>忘记密码?</text>
</view>
</view>
<!-- 注册 -->
<view class="input-box" hidden="{{current==1}}">
<view class="wei-input">
<icon type="waiting" color="#44ADFB" size="16"></icon>
<input class="input" auto-focus placeholder="请输入手机号"/>
</view>
<view class="wei-input">
<icon type="waiting" color="#44ADFB" size="16"></icon>
<<input class="input" auto-focus placeholder="请输入6位验证码"/>
<text class="input-code" bindtap="getCode">{{codeText}}</text>
</view>
<view class="wei-input">
<icon type="success" color="#44ADFB" size="16"></icon>
<input class="input" auto-focus placeholder="请输入密码"/>
</view>
<view class="wei-input">
<icon type="success" color="#44ADFB" size="16"></icon>
<<input class="input" auto-focus placeholder="请确认密码"/>
</view>
</view>
<view class="sumbit-btn">
<button class="button" style="background-color: #33ccff;font-size: 30rpx;" type="primary">立即{{current==1?'登录':'注册'}}</button>
</view>
</view>
<!-- 重影 -->
<view class="shadow shadow-1"></view>
<view class="shadow shadow-2"></view>
<!-- 说明 -->
<!-- js代码 -->
<script>
Page({
data: {
current: 0, // 当前显示的页面,0为注册,1为登录
codeText: '获取验证码',
},
click: function(e) {
this.setData({
current: e.target.dataset.code
})
},
getCode: function() {
// 获取验证码的逻辑
}
})
</script>
<!--pages/complete/complete.wxml--> <navigator url="../address/address"> <view wx:if="{{hasAddress}}" class="orders-address"> <text class="orders-address-name">收货人: {{address.name}}</text> <text class="orders-address-phone">电话: {{address.phone}}</text> <view class="orders-address-detail">{{address.detail}}</view> </view> <view wx:else class="orders-no-address">添加收货地址</view> </navigator> <view class="order_pay_wrap" bindtap="balance1"> 结算 </view>帮我优化这个代码,并且写一个漂亮的wxss
<!--pages/complete/complete.wxml-->
<view class="container">
<navigator url="../address/address">
<view class="address-wrapper">
<view wx:if="{{hasAddress}}" class="address">
<text class="name">{{address.name}}</text>
<text class="phone">{{address.phone}}</text>
<view class="detail">{{address.detail}}</view>
</view>
<view wx:else class="no-address">添加收货地址</view>
<image class="arrow" src="../../images/arrow-right.png"></image>
</view>
</navigator>
<view class="pay-button" bindtap="balance1">结算</view>
</view>
/* pages/complete/complete.wxss */
.container {
padding: 20rpx;
background-color: #F2F2F2;
}
.address-wrapper {
display: flex;
align-items: center;
justify-content: space-between;
background-color: #FFFFFF;
border-radius: 10rpx;
padding: 20rpx;
margin-bottom: 20rpx;
}
.address {
display: flex;
flex-direction: column;
}
.name {
font-size: 28rpx;
font-weight: bold;
margin-bottom: 10rpx;
}
.phone {
font-size: 26rpx;
color: #666666;
margin-bottom: 20rpx;
}
.detail {
font-size: 26rpx;
color: #666666;
line-height: 1.5;
}
.no-address {
font-size: 28rpx;
color: #666666;
}
.arrow {
width: 30rpx;
height: 30rpx;
}
.pay-button {
display: block;
width: 100%;
background-color: #FFC900;
color: #FFFFFF;
font-size: 32rpx;
text-align: center;
padding: 20rpx;
border-radius: 10rpx;
}
相关推荐















