uniapp制作小程序三个页面的源码

时间: 2023-08-02 18:07:28 浏览: 128
以下是一个简单的 Uniapp 小程序项目中的三个页面的源码示例: 1. 首页(index.vue) ```html <template> <view class="container"> <text class="title">欢迎来到我的小程序</text> <view class="button" @tap="goToList"> <text>进入列表页</text> </view> </view> </template> <script> export default { methods: { goToList() { uni.navigateTo({ url: '/pages/list/list' }) } } } </script> <style> .container { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100vh; } .title { font-size: 24px; margin-bottom: 20px; } .button { background-color: #007AFF; color: #fff; display: flex; justify-content: center; align-items: center; width: 200px; height: 50px; border-radius: 25px; } </style> ``` 2. 列表页(list.vue) ```html <template> <view class="container"> <text class="title">商品列表</text> <view class="list-item" v-for="(item, index) in list" :key="index" @tap="goToDetail(item.id)"> <text class="item-title">{{ item.title }}</text> <text class="item-price">{{ item.price }}</text> </view> </view> </template> <script> export default { data() { return { list: [ { id: 1, title: '商品1', price: '100元' }, { id: 2, title: '商品2', price: '200元' }, { id: 3, title: '商品3', price: '300元' }, { id: 4, title: '商品4', price: '400元' }, { id: 5, title: '商品5', price: '500元' }, ] } }, methods: { goToDetail(id) { uni.navigateTo({ url: '/pages/detail/detail?id=' + id }) } } } </script> <style> .container { padding: 20px; } .title { font-size: 24px; margin-bottom: 20px; } .list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid #eee; } .item-title { font-size: 18px; } .item-price { color: #f00; } </style> ``` 3. 详情页(detail.vue) ```html <template> <view class="container"> <text class="title">{{ detail.title }}</text> <text class="price">{{ detail.price }}</text> <text class="desc">{{ detail.desc }}</text> </view> </template> <script> export default { data() { return { detail: {} } }, onLoad(options) { const id = options.id // 根据id获取详情数据 this.detail = { id: id, title: '商品' + id, price: id * 100 + '元', desc: '这是商品' + id + '的详细介绍。' } } } </script> <style> .container { padding: 20px; } .title { font-size: 24px; margin-bottom: 20px; } .price { color: #f00; font-size: 20px; margin-bottom: 10px; } .desc { font-size: 16px; line-height: 1.5; } </style> ``` 以上代码仅供参考,实际项目中的页面代码会根据具体需求有所不同。

相关推荐

最新推荐

recommend-type

微信小程序实现点击文字页面跳转功能【附源码下载】

本文实例讲述了微信小程序实现点击文字页面跳转功能。分享给大家供大家参考,具体如下: 1、效果展示 2、关键代码 index.js文件 Page({ data:{ // text:"这是一个页面" }, onLoad:function(options){ // 页面...
recommend-type

微信小程序 表单Form实例详解(附源码)

主要介绍了微信小程序 表单Form实例详解的相关资料,这里对form 表单进行了详细介绍,并附实例代码,需要的朋友可以参考下
recommend-type

微信小程序连续签到7天积分获得功能的示例代码

今天通过一个案例给大家分享微信小程序连续签到7天积分获得功能,通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考价值,感兴趣的朋友一起学习吧
recommend-type

如何获取别人微信小程序的源文件?

简单思考一下我们使用小程序的场景就会明白,当我们点开一个微信小程序的时候,其实是微信已经将它的从服务器上下载到了手机,然后再来运行的。所以,虽然我们没能力从服务器上获取到,但是我们应该可以从手机本地...
recommend-type

筷子系统源码筷子视频制作部份源码展示

筷子系统源码筷子视频制作部份源码展示 功能列表初版清单: 视频智能裂变 短视频AI智能分拆 一键分拆视频,10倍提升效率 短视频脚本混剪 单人每日产量提升1000条,节省数十万剪辑成本 短视频智能制作 短视频智能分...
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

list根据id查询pid 然后依次获取到所有的子节点数据

可以使用递归的方式来实现根据id查询pid并获取所有子节点数据。具体实现可以参考以下代码: ``` def get_children_nodes(nodes, parent_id): children = [] for node in nodes: if node['pid'] == parent_id: node['children'] = get_children_nodes(nodes, node['id']) children.append(node) return children # 测试数
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。