首页就在index里面做了样式的修改:

    1. <template>
    2. <view class='home'>
    3. <swiper indicator-dots circular>
    4. <swiper-item v-for='item in swipers' :key='item.id'>
    5. <image :src='item.img'></image>
    6. </swiper-item>
    7. </swiper>
    8. <!--导航-->
    9. <view class='nav'>
    10. <view class='nav_item'>
    11. <view class='iconfont icon-ziyuan'></view>
    12. <text>黑马超市</text>
    13. </view>
    14. <view class='nav_item'>
    15. <view class='iconfont icon-guanyuwomen'></view>
    16. <text>联系我们</text>
    17. </view>
    18. <view class='nav_item'>
    19. <view class='iconfont icon-tupian'></view>
    20. <text>社区图片</text>
    21. </view>
    22. <view class='nav_item'>
    23. <view class='iconfont icon-shipin'></view>
    24. <text>学习视频</text>
    25. </view>
    26. </view>
    27. <!--推荐商品-->
    28. <view class='hot_goods'>
    29. <view class='tit'>推荐商品</view>
    30. <view class='goods_list'>
    31. <view class='goods_item'>
    32. <image src='http://destiny001.gitee.io/image/ban3.jpg'></image>
    33. <view class='price'>
    34. <text>¥2199</text>
    35. <text>¥2199</text>
    36. </view>
    37. <view class="name">
    38. 华为苹果电脑,大晒的好事大点哈送到
    39. </view>
    40. </view>
    41. <view class='goods_item'>
    42. <image src='http://destiny001.gitee.io/image/ban3.jpg'></image>
    43. <view class='price'>
    44. <text>¥2199</text>
    45. <text>¥2199</text>
    46. </view>
    47. <view class="name">
    48. 华为苹果电脑,大晒的好事大点哈送到
    49. </view>
    50. </view>
    51. <view class='goods_item'>
    52. <image src='http://destiny001.gitee.io/image/ban3.jpg'></image>
    53. <view class='price'>
    54. <text>¥2199</text>
    55. <text>¥2199</text>
    56. </view>
    57. <view class="name">
    58. 华为苹果电脑,大晒的好事大点哈送到
    59. </view>
    60. </view>
    61. </view>
    62. </view>
    63. </view>
    64. </template>
    65. <script>
    66. export default {
    67. data() {
    68. return {
    69. swipers:[]
    70. }
    71. },
    72. onLoad() { //监听页面加载
    73. this.getSwiper()
    74. },
    75. methods: {
    76. //获取轮播的数据
    77. // async getSwiper(){
    78. // console.log('获取轮播的数据')
    79. // const res = await uni.request({
    80. // url:'http://localhost:8082/api/getlunbo',
    81. // })
    82. // console.log(res.data)
    83. // }
    84. //获取轮播数据
    85. async getSwiper(){
    86. // console.log('获取轮播的数据')
    87. // uni.request({
    88. // url:'http://localhost:8082/api/getlunbo',
    89. // success:res=>{
    90. // console.log(res.data.message)
    91. // if(res.data.status !== 0){
    92. // return uni.showToast({
    93. // title:'获取数据失败'
    94. // })
    95. // }
    96. // this.swipers = res.data.message
    97. // }
    98. // })
    99. const res =await this.$myRequest({
    100. url:'/api/getlunbo'
    101. })
    102. this.swipers = res.data.message
    103. }
    104. }
    105. }
    106. </script>
    107. <style lang="scss">
    108. .home{
    109. swiper{
    110. width:750rpx;
    111. height: 380rpx;
    112. image{
    113. height:100%;
    114. width:100%;
    115. }
    116. }
    117. .nav{
    118. display: flex;
    119. .nav_item{
    120. width:25%;
    121. text-align: center;
    122. view{
    123. width: 120rpx;
    124. height:120rpx;
    125. background-color: $shop-color; //这个变量是在uni.scss文件里面定义的!
    126. border-radius: 60rpx;
    127. margin: 10px auto;
    128. line-height: 120rpx;
    129. color:#fff;
    130. font-size:50rpx;
    131. }
    132. .icon-tupian{
    133. font-size:45rpx;
    134. }
    135. text{
    136. font-size: 30rpx;
    137. }
    138. }
    139. }
    140. .hot_goods{
    141. background: #eee;
    142. overflow:hidden;
    143. margin-top: 10px;
    144. .tit{
    145. height:50px;
    146. line-height: 50px;
    147. color:$shop-color;
    148. text-align: center;
    149. letter-spacing: 20px;
    150. font-size: 20px;
    151. margin:7rpx 0;
    152. background: #fff;
    153. }
    154. .goods_list{
    155. padding:0 15rpx;
    156. display: flex;
    157. flex-wrap: wrap;
    158. justify-content: space-between;
    159. .goods_item{
    160. background: #fff;
    161. width:355rpx;
    162. margin:10rpx 0;
    163. padding: 15rpx;
    164. box-sizing: border-box;//不会撑开盒子了
    165. image{
    166. width:95%;
    167. height:200px;
    168. display:block;
    169. margin:0 auto; //上面下面实现居中
    170. }
    171. .price{
    172. color:$shop-color;
    173. font-size: 36rpx;
    174. text:nth-child(2){
    175. color:#CCC;
    176. font-size: 28rpx;
    177. margin-left:17rpx;
    178. text-decoration: line-through;
    179. }
    180. }
    181. .name{
    182. font-size:32rpx;
    183. line-height:50rpx;
    184. }
    185. }
    186. }
    187. }
    188. }
    189. </style>

    具体的样式如下:
    image.png