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

uni-app学习笔记01-项目初始化及相关文件

使用新的IDE HBuilder X   uni-app官方文档 快速上手

此项目创建使用vue3版本,文件结构与vue3类似

相关功能示例:

pages.json中配置路由和导航栏tabBar

{"pages": [ //用于配置路由,pages数组中第一项表示应用启动页{"path": "pages/index/index", //文件路径"style": {"navigationBarTitleText": "酱梨食刻" //页面名字}},{"path" : "pages/Discover/Discover","style" : {"navigationBarTitleText" : "发现店铺"}},{"path" : "pages/Random/Random","style" : {"navigationBarTitleText" : "随机一餐"}},{"path" : "pages/Profile/Profile","style" : {"navigationBarTitleText" : "个人中心"}}],"globalStyle": {"navigationBarTextStyle": "white", //配置窗口上方的字体颜色"navigationBarTitleText": "uni-app","navigationBarBackgroundColor": "#667eea", //配置窗口上方的背景色"backgroundColor": "#F8F8F8"},"tabBar": {    //配置导航栏"selectedColor": "#667eea",//选中字体的颜色"list": [{"pagePath": "pages/index/index", //对应导航路径"text": "首页", //导航栏的名字"iconPath": "/static/styles/ali-iconfont/png/shouye6.png", //未选中图标路径"selectedIconPath": "/static/styles/ali-iconfont/active-png/shouye6.png" //选择中图标路径},{"pagePath": "pages/Discover/Discover","text": "发现","iconPath": "/static/styles/ali-iconfont/png/faxian.png","selectedIconPath": "/static/styles/ali-iconfont/active-png/faxian.png"},{"pagePath": "pages/Random/Random","text": "随机","iconPath": "/static/styles/ali-iconfont/png/suijishushengcheng.png","selectedIconPath": "/static/styles/ali-iconfont/active-png/suijishushengcheng.png"},{"pagePath": "pages/Profile/Profile","text": "我的","iconPath": "/static/styles/ali-iconfont/png/li.png","selectedIconPath": "/static/styles/ali-iconfont/active-png/li.png"}]},"uniIdRouter": {}
}

 

在uvue文件中,也是由

这三部分组成,可根据习惯,将script部分移动至上方,不影响

运行至微信小程序时需要运行设置中把路径改为微信开发者工具应用程序的路径

在uni-app的模板中,view组件就类似于div,text就类似于span 

配置hover-class就可以做点击时的效果

新加的组件 配置一个可以滚动的区域

如果要配置横向滚动的话

需要三步 y改为x 子组件设置display:inline-block 父组件设置white-space: nowrap;

<scroll-view scroll-x class="scrollView"><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view></scroll-view>
<style lang="scss">
.scrollView{width: 750rpx;height: 300rpx;border: 1px solid pink;white-space: nowrap;.box{height: 200rpx;width: 200rpx;background-color: skyblue;border: 1px solid red;display: inline-block;}}
</style>

直接用的轮播图

 

<script setup>const picList=[{id:'1',url:"https://pic2.zhimg.com/v2-d1286ae973d1ad3b94d32b45d783f4ab_r.jpg?source=1940ef5c"},{id:'2',url:"https://c-ssl.duitang.com/uploads/blog/202011/21/20201121154203_47c2c.thumb.1000_0.png"},{id:'3',url:"https://c-ssl.duitang.com/uploads/blog/202201/02/20220102144252_1e9a0.jpg"},{id:'4',url:"https://ts2.tc.mm.bing.net/th/id/OIP-C.QUlIh_eLkMYxBljVXO5ChgHaEo?r=0&rs=1&pid=ImgDetMain&o=7&rm=3"},{id:'5',url:"https://pic3.zhimg.com/v2-d96c7a9c2492de35b5e75fda2255614f_r.jpg"},]
</script><template><swiper class="banner" indicator-dots autoplay><swiper-item v-for="item in picList" :key="item.id"><image :src="item.url"></image></swiper-item></swiper><scroll-view scroll-x class="scrollView"><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view><view class="box"></view></scroll-view>
</template><style lang="scss">.banner{width: 750rpx;height: 500rpx;overflow: hidden;image{width: 100%;height: 100%;object-fit: contain;}}.scrollView{width: 750rpx;height: 300rpx;border: 1px solid pink;white-space: nowrap;.box{height: 200rpx;width: 200rpx;background-color: skyblue;border: 1px solid red;display: inline-block;}}
</style>

http://www.xdnf.cn/news/17007.html

相关文章:

  • 控制建模matlab练习10:滞后补偿器
  • sqli-labs:Less-25关卡详细解析
  • Go语法:闭包
  • 【银行测试】银行票据项目业务+票据测试点分析(二)
  • Android 之 网络通信(HTTP/TCP/UDP/JSON)
  • LeetCode Hot 100,快速学习,不断更
  • MySQL连接算法和小表驱动大表的原理
  • Parcel 使用详解:零配置的前端打包工具
  • 力扣经典算法篇-39-有效的数独(二维数组和三维数组的应用)
  • 机器学习第三课之逻辑回归(三)LogisticRegression
  • 【Linux】linux基础开发工具(三) 版本控制器Git、调试器 - gdb/cgdb使用、一些实用的调试技巧
  • 关于逻辑回归的相关知识大全
  • 【数据分享】南京诗歌文学地理数据集(获取方式看文末)
  • Mongo索引
  • SpringBoot项目数据脱敏(自定义注解)
  • PPT自动化 python-pptx - 10 : 表格(tables)
  • kotlin kmp 跨平台环境使用sqldelight
  • 【从零开始速通C语言1】 - 汇编语言1
  • 【前端安全】聊聊 HTML 闭合优先级和浏览器解析顺序
  • 《嵌入式数据结构笔记(一):数据结构导论与链表》
  • Libevent(5)之使用教程(4)工具
  • 对接古老系统的架构实践:封装混乱,走向有序
  • 《从原理到实践:MySQL索引优化与SQL性能调优全解析》
  • Axios介绍
  • 达梦数据库备份与还原终极指南:从基础到增量策略实战
  • k8s+isulad 国产化技术栈云原生技术栈搭建4-添加worker节点
  • 使用Database Navigator插件进行连接sqlite报错invalid or incomplete database
  • 新电脑上GitHub推送失败?全面排查与解决指南
  • 力扣经典算法篇-41-旋转图像(辅助数组法,原地旋转法)
  • 基于深度学习的医学图像分析:使用变分自编码器(VAE)实现医学图像生成