uniapp 微信小程序 城市索引列表

最近做的一个项目需要频繁用到城市列表切换,切换城市,腾讯地图虽然有地图列表,但是效果不是自己项目想要的,于是就结合结合uview的IndexList 索引列表重新做了一个城市列表的页面

效果图:

 页面结构:address.vue

/**
*
* name: 城市列表选择
* @property {Array}  data: hotCity 热门城市 eg: <!-- ['北京', '上海', '天津', '重庆', '广州', '深圳', '成都', '杭州'] -->
* @property {Array} cityList 全国市 eg: 这是我项目的城市数据
<!-- [{data:[{carNumber: "川U",code: "513200",fullName: "阿坝藏族羌族自治州",fullNameAbbrPinYin:"ABZZQZZZZ",parentCode: "510000",shortName: "阿坝藏族羌族自治州",type: 3}],letter: "A"}] -->
* @property {Array}  indexList 索引 eg: ["A","B", "C", ....]
*/
<template>
	<view class="content" style="height: calc(100vh - 40rpx); overflow: hidden;">
		<navBar :item='{leftText:leftText,leftIcon:leftIcon,leftIconColor:leftIconColor, navTitle: navTitle,
			bgColor:bgColor}'></navBar>
		<!-- 搜素 -->
		<view class="search-city">
			<u-search v-model="searchValue" bgColor="#fff" placeholderColor="#CECCCC" :showAction="true" @change="changeClick"
				actionText="搜索" :animation="false" clearabled @custom="customClick"></u-search>
		</view>
		<view v-if="searchValue" style="height: calc(100vh - 40rpx - 64px - 34px);overflow-y: scroll">
			<view v-if="searchArr.l
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
UniApp评论页面的实现方式是通过使用Vue的循环指令(v-for)来遍历评论列表,并使用组件来展示每条评论的内容。具体的步骤如下: 1. 创建一个 `<template>` 元素,用于放置评论内容。 2. 在 `<template>` 元素中,使用 `v-for` 指令来循环遍历评论列表。 3. 对于每个评论,创建一个 `<uni-card>` 组件,用于显示评论内容。 4. 在 `<uni-card>` 组件中,添加一个标题、评论内容、评论日期和用户头像等信息。 5. 在页面中引入 `<template>` 元素,并使用评论列表数据渲染评论界面。 以下是一个示例代码: ```html <template> <view class="comment-list"> <view v-for="(item, index) in commentList" :key="index"> <uni-card> <view slot="header"> <view class="user-info"> <image :src="item.avatar"></image> <text class="username">{{ item.username }}</text> </view> <view class="comment-date">{{ item.date }}</view> </view> <view slot="content"> <text>{{ item.content }}</text> </view> </uni-card> </view> </view> </template> <script> export default { data() { return { commentList: [ { username: '张三', avatar: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/shuijiao.jpg', content: '这是一条评论内容', date: '2022-01-01' }, { username: '李四', avatar: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/muwu.jpg', content: '这是另一条评论内容', date: '2022-02-01' } ] } } } </script> <style> .comment-list { padding: 20rpx; } </style> ``` 以上代码使用了 `<uni-card>` 组件作为评论项的展示容器,通过循环遍历 `commentList` 数据来生成多个评论项。每个评论项包含了评论的作者信息、评论内容和评论日期。 你可以根据需要修改组件样式和数据结构来适应具体的评论页面设计和功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值