当前位置: 首页 > news >正文

EP12 分类列表元素点击跳转

文件路径: E:/homework/uniappv3tswallpaper/pages.json

{"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages{"path": "pages/index/index","style": {"navigationBarTitleText": "uni-app","navigationStyle": "custom"}},{"path": "pages/classify/classify","style": {"navigationBarTitleText": "classify","navigationStyle": "custom"}},{"path": "pages/user/user","style": {"navigationBarTitleText": "user","navigationStyle": "custom"}},{"path": "pages/classlist/classlist","style": {"navigationBarTitleText": "classlist","navigationStyle": "custom"}}],"globalStyle": {"navigationBarTextStyle": "black","navigationBarTitleText": "壁纸","navigationBarBackgroundColor": "#fff","backgroundColor": "#F8F8F8"},"tabBar": {"color": "#9799a5","selectedColor": "#28B389","list": [{"text": "分类","pagePath": "pages/classify/classify","iconPath": "static/images/tabBar/classify.png","selectedIconPath": "static/images/tabBar/classify-h.png"}, {"text": "推荐","pagePath": "pages/index/index","iconPath": "static/images/tabBar/home.png","selectedIconPath": "static/images/tabBar/home-h.png"}, {"text": "我的","pagePath": "pages/user/user","iconPath": "static/images/tabBar/user.png","selectedIconPath": "static/images/tabBar/user-h.png"}]},"uniIdRouter": {}
}

给每个 tabbar 中的页面添加上 navigationStyle 属性。

文件路径: E:/homework/uniappv3tswallpaper/components/theme-item/theme-item.vue

<template><view class="themeItem"><navigator url="/pages/classlist/classlist" class="box" v-if="!isMore"><image class="pic" src="../../common/images/classify1.jpg" mode="aspectFill"></image><view class="mask">明星美女</view><view class="tab">3天前更新</view></navigator><navigator url="/pages/classify/classify" open-type="reLaunch" class="box more" v-if="isMore"><image class="pic" src="../../common/images/more.jpg" mode="aspectFill"></image><view class="mask"><uni-icons type="more-filled" size="34" color="#fff"></uni-icons><view class="text">更多</view></view></navigator></view>
</template><script setup>defineProps({isMore: {type: Boolean,default: false}})
</script><style lang="scss">.themeItem {.box {height: 340rpx;border-radius: 10rpx;overflow: hidden;position: relative;.pic {width: 100%;height: 100%;}.mask {position: absolute;bottom: 0;left: 0;width: 100%;height: 70rpx;background-color: rgba(0, 0, 0, 0.2);color: #fff;display: flex;align-items: center;justify-content: center;font-weight: 600;backdrop-filter: blur(20rpx);}.tab {position: absolute;left: 0%;top: 0%;background: rgba(250, 190, 90, 0.7);backdrop-filter: blur(20rpx);color: #fff;padding: 6rpx 14rpx;border-radius: 0 0 20rpx 0;transform: scale(0.8);transform-origin: left top;}}.box.more {.mask {height: 100%;width: 100%;flex-direction: column;}.text {font-size: 28rpx;}}}
</style>

分类页面中的每一项都是全局组件 theme-item ,所以在组件上直接添加 url

并且 more 组件中的跳转目标页面同样是 tabbar 中的页面,所以需要添加 open-type 属性。

文件路径: E:/homework/uniappv3tswallpaper/pages/user/user.vue

<template><view class="userLayout pageBg"><view class="userInfo"><view class="avatar"><image src="../../common/images/preview1.jpg" mode="aspectFill"></image></view><view class="ip">100.100.100.100</view><view class="from">中国山东</view></view><view class="section"><view class="list"><navigator url="/pages/classlist/classlist"><view class="row"><view class="left"><uni-icons type="download-filled" size="20" color="#28b389"></uni-icons><view class="text">我的下载</view></view><view class="right"><view class="text">33</view><uni-icons type="right" size="15" color="#aaa"></uni-icons></view></view></navigator><navigator url="/pages/classlist/classlist"><view class="row"><view class="left"><uni-icons type="star-filled" size="20" color="#28b389"></uni-icons><view class="text">我的评分</view></view><view class="right"><view class="text">33</view><uni-icons type="right" size="15" color="#aaa"></uni-icons></view></view></navigator><view class="row"><view class="left"><uni-icons type="chatboxes-filled" size="20" color="#28b389"></uni-icons><view class="text">联系客服</view></view><view class="right"><view class="text"></view><uni-icons type="right" size="15" color="#aaa"></uni-icons></view><!-- #ifdef MP --><button open-type="contact">联系客服</button><!-- #endif --><!-- #ifndef MP --><button @click="clickContact">打电话</button><!-- #endif --></view></view></view><view class="section"><view class="list"><view class="row"><view class="left"><uni-icons type="notification-filled" size="20" color="#28b389"></uni-icons><view class="text">订阅更新</view></view><view class="right"><view class="text"></view><uni-icons type="right" size="15" color="#aaa"></uni-icons></view></view><view class="row"><view class="left"><uni-icons type="flag-filled" size="20" color="#28b389"></uni-icons><view class="text">常见问题</view></view><view class="right"><view class="text"></view><uni-icons type="right" size="15" color="#aaa"></uni-icons></view></view></view></view></view>
</template><script setup>const clickContact = () => {uni.makePhoneCall({phoneNumber: '114' //仅为示例});}
</script><style lang="scss" scoped>.userLayout {.userInfo {display: flex;flex-direction: column;flex-wrap: nowrap;align-content: center;justify-content: center;align-items: center;padding: 50rpx 0;.avatar {height: 160rpx;width: 160rpx;border-radius: 50%;overflow: hidden;image {height: 100%;width: 100%;}}.ip {font-size: 44rpx;color: #333;padding: 20rpx 0 5rpx;}.from {font-size: 28rpx;color: #aaa;}}}.section {width: 690rpx;margin: 50rpx auto;border: 1rpx solid #eee;border-radius: 10rpx;border-shadow: 0 0 30rpx rgba(0, 0, 0, 0.2);.list {.row {display: flex;flex-direction: row;flex-wrap: nowrap;align-content: center;justify-content: space-between;align-items: center;padding: 0 30rpx;height: 100rpx;border-bottom: 1px solid #eee;position: relative;background: white;:last-child {border-bottom: 0;}.left {display: flex;flex-direction: row;flex-wrap: nowrap;align-content: center;align-items: center;.text {padding-left: 20rpx;color: #666}}.right {display: flex;flex-direction: row;flex-wrap: nowrap;align-content: center;align-items: center;.text {padding-left: 20rpx;color: #666}}button {position: absolute;top: 0%;left: 0%;height: 100%;width: 100%;opacity: 0}}}}
</style>

user 页面中也有需要跳转到详情列表页面的情况。

文件路径: E:/homework/uniappv3tswallpaper/pages/classlist/classlist.vue

<template><view class="classlist"><view class="content"><navigator url="" class="item" v-for="item in 10"><image src="../../common/images/preview2.jpg" mode="aspectFill"></image></navigator></view></view>
</template><script setup></script><style lang="scss">.classlist {.content {display: grid;grid-template-columns: repeat(3, 1fr);gap: 5px;padding: 5rpx;.item {height: 440rpx;width: 100%;image {height: 100%;width: 100%;display: block;}}}}
</style>

详情列表页面单独写成一个页面。

注意:
user 页面中实现跳转的时候,如果将元素的 view 标签改为 navigator 标签,可能会因为 navigator 标签的内置 a 标签而造成布局错乱。
可以在 view 标签外层直接套用 navigator 标签,完美解决这个问题。

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 医学数据分析实训 项目一 医学数据采集
  • 深入解读Docker核心原理:Namespace资源隔离机制详解
  • SPDK 部署NVMe over TCP
  • golang学习笔记19——golang做服务发现与注册的深度剖析
  • PHP在现代Web开发中的高效应用与最佳实践
  • 【C++】模拟实现string类
  • LabVIEW重构其他语言开发的旧系统
  • 个人hic分析流程搭建4—compartment模块分析
  • 切线空间:unity中shader切线空间,切线矩阵,TBN矩阵 ,法线贴图深度剖析
  • 基于人工智能的自动驾驶系统项目教学指南
  • 三星ZFlip5/ZFlip4/W7024刷安卓14国行OneUI6.1系统-高级设置-韩/欧/港版
  • StreamReader 和 StreamWriter提供自动处理字符编码的功能
  • AI+摄影:行业变革与创新机遇
  • 建筑工程资料保护策略:打造安全的建筑文档管理方案
  • 【数据结构精讲】01绪论(基本概念介绍和时间复杂度计算)
  • 【402天】跃迁之路——程序员高效学习方法论探索系列(实验阶段159-2018.03.14)...
  • 【附node操作实例】redis简明入门系列—字符串类型
  • java2019面试题北京
  • Java反射-动态类加载和重新加载
  • Twitter赢在开放,三年创造奇迹
  • Web Storage相关
  • XForms - 更强大的Form
  • yii2中session跨域名的问题
  • 代理模式
  • 翻译 | 老司机带你秒懂内存管理 - 第一部(共三部)
  • 翻译:Hystrix - How To Use
  • 关于使用markdown的方法(引自CSDN教程)
  • 前端面试题总结
  • 如何胜任知名企业的商业数据分析师?
  • 入门级的git使用指北
  • 什么是Javascript函数节流?
  • 实战|智能家居行业移动应用性能分析
  • 在weex里面使用chart图表
  • postgresql行列转换函数
  • 数据可视化之下发图实践
  • 完善智慧办公建设,小熊U租获京东数千万元A+轮融资 ...
  • ​低代码平台的核心价值与优势
  • ​二进制运算符:(与运算)、|(或运算)、~(取反运算)、^(异或运算)、位移运算符​
  • ​软考-高级-系统架构设计师教程(清华第2版)【第12章 信息系统架构设计理论与实践(P420~465)-思维导图】​
  • # AI产品经理的自我修养:既懂用户,更懂技术!
  • #Z2294. 打印树的直径
  • #经典论文 异质山坡的物理模型 2 有效导水率
  • #数学建模# 线性规划问题的Matlab求解
  • $emit传递多个参数_PPC和MIPS指令集下二进制代码中函数参数个数的识别方法
  • $redis-setphp_redis Set命令,php操作Redis Set函数介绍
  • (17)Hive ——MR任务的map与reduce个数由什么决定?
  • (2009.11版)《网络管理员考试 考前冲刺预测卷及考点解析》复习重点
  • (6)STL算法之转换
  • (pytorch进阶之路)扩散概率模型
  • (Windows环境)FFMPEG编译,包含编译x264以及x265
  • (不用互三)AI绘画工具应该如何选择
  • (分享)自己整理的一些简单awk实用语句
  • (附源码)ssm高校社团管理系统 毕业设计 234162
  • (附源码)ssm智慧社区管理系统 毕业设计 101635
  • (十一)c52学习之旅-动态数码管