壁纸小程序Vue3(首页布局)

这篇具有很好参考价值的文章主要介绍了壁纸小程序Vue3(首页布局)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1.创建一个公共目录common来存放css和images

App.vue中引用

<style lang="scss">
    /*每个页面公共css */
  @import 'common/style/common-style.scss';
  
  
</style>
 

 2.渲染轮播图

壁纸小程序Vue3(首页布局),壁纸小程序Vue3,小程序

<template>
	<view class="homeLayout">
      <view class="banner">
        <swiper indicator-dots indicator-color="rgba(255,255,255,0.5)"
          indicator-active-color="#fff" autoplay
          circular
        >
          <swiper-item v-for="item in 3" >
              <image src="../../common/images/lxja.webp" mode="widthFix"></image>
          </swiper-item>
        </swiper>
      </view>
	</view>
</template>

<script setup>

	
</script>

<style lang="scss" scoped>
	.homeLayout{
    .banner{
      width: 750rpx;
      padding: 30rpx 0;
      swiper{
        width: 750rpx;
        height: 340rpx;
      
        // swiper-item{}
        //简化
        &-item{
          width: 100%;
          height: 100%;
          padding: 0 30rpx;
          image{
            width: 100%;
            height: 100%;
            border-radius: 10rpx;
          }
        }
      }
    }
  }
</style>

3.公告的轮播

壁纸小程序Vue3(首页布局),壁纸小程序Vue3,小程序

  <view class="notice">
          <view class="left">
              <uni-icons type="sound-filled" size="20" color="#28b389"></uni-icons>
              <text class="text">公告</text>
          </view>
          <view class="center">
              <swiper vertical autoplay interval="1500" duration="300" circular>
                    <swiper-item v-for="item in 4">文字内容文字内容文字内容文字内容文字内容文字内容</swiper-item>
              </swiper>
          </view>
          <view class="right">
                <uni-icons type="right" size="16" color="#333"></uni-icons>
          </view>
          
      </view>
  .notice{
      width: 690rpx;
      height: 80rpx;
      line-height: 80rpx;
      background: #f9f9f9;
      margin: 0 auto;
      border-radius: 80rpx;
      display: flex;
      .left{
        width: 140rpx;
        display: flex;
        align-items: center;
        justify-content: center;
        .text{
          color: #28b389;
          font-weight: 600;
          font-size: 28rpx;
        }
      }
      .center{
        flex: 1;
        swiper{
          height: 100%;
          &-item{
            height: 100%;
            font-size: 30rpx;
            color: #666;
            //超出的文字用...替换
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
      }
      .right{
        width: 70rpx;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }

4.渲染公告下的内容

壁纸小程序Vue3(首页布局),壁纸小程序Vue3,小程序

创建公共标题组件common-title

 <view class="select">
          <common-title></common-title>
          <view class="content">
              <scroll-view scroll-x>
                <view class="box" v-for="item in 8">
                    <image src="../../common/images/lxja.webp" mode="aspectFill"></image>
                </view>
              </scroll-view>
          </view>
      </view>

将元素的display属性设置为inline-block可以让元素既有行内元素可以一行显示多个的特性,又有块级元素可以设置宽高的特性。 

 

.select{
      padding-top: 50rpx;
      .content{
        width: 720rpx;
        margin-left: 30rpx;
        margin-top: 30rpx;
        scroll-view{
          white-space: nowrap;
          .box{
            width: 200rpx;
            height: 430rpx;
            display: inline-block;
            margin-right: 15rpx;
            image{
              width: 100%;
              height: 100%;
              border-radius: 10rpx;
            }
          }
          .box:last-child{
            margin-right: 30rpx;
          }
        }
      }
    }
    

5.引入插槽定义公共标题模块

common-title

<template>
  <view class="common-title">
      <view class="name">
        <!-- 插槽 -->
        <slot name="name"></slot>
      </view>
      <view class="custom">
        <slot name="custom"></slot>
      </view>
  </view>
</template>

<script setup>
 
</script>

<style lang="scss" scoped>
.common-title{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30rpx;
  .name{
    font-size: 40rpx;
  }
}
</style>

index.vue

  <view class="select">
          <common-title>
              <template #name>每日推荐</template>
              <template #custom>
                <view class="date">
                    <uni-icons type="calendar" size="18" color="#28b389"></uni-icons>
                    <view>
                        <uni-dateformat :date="Date.now()" format="dd日"></uni-dateformat>
                    </view>
                </view>
              </template>
          </common-title>
          <view class="content">
              <scroll-view scroll-x>
                <view class="box" v-for="item in 8">
                    <image src="../../common/images/lxja.webp" mode="aspectFill"></image>
                </view>
              </scroll-view>
          </view>
      </view>
      
      <view class="theme">
          <common-title>
            <template #name>专题精选</template>
            <template #custom>
              <navigator url="" class="more">More+</navigator>
            </template>
          </common-title>
      </view>

6.渲染专题精选

壁纸小程序Vue3(首页布局),壁纸小程序Vue3,小程序

 index.vue

 <view class="theme">
          <common-title>
            <template #name>专题精选</template>
            <template #custom>
              <navigator url="" class="more">More+</navigator>
            </template>
          </common-title>
          <view class="content">
              <theme-item v-for="item in 8"></theme-item>
          </view>
      </view>

 

.theme{
        padding-top: 50rpx;
        .more{
          font-size: 32rpx;
          color: #888;
        }
        .content{
          margin-top: 30rpx;
          padding: 0 30rpx;
          //网格布局
          display: grid;
          //每个元素中间有一个间隙
          gap: 15rpx;
          //一行展示三个每行平均分配
          grid-template-columns: repeat(3,1fr);
        }
    }

新创建一个组件them-item

<template>
  <view class="themeTtem">
      <navigator url="" class="box">
        <image class="pic" src="https://img1.baidu.com/it/u=871832137,2572636834&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=1198" mode="aspectFill"></image>
        <view class="mask">盛世美颜</view>
        <view class="tab">3天前更新</view>
      </navigator>
  </view>
</template>

.themeTtem{
  .box{
    height: 340rpx;
    border-radius: 10rpx;
    //不加overflow:圆角显示不出来
    overflow: hidden;
    position: relative;
    .pic{
      width: 100%;
      height: 100%;
    }
    .mask{
      width: 100%;
      height: 70rpx;
      position: absolute;
      bottom: 0;
      left: 0;
      //磨砂透明
      background: rgba(0,0,0,0.2);
      color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      //模糊滤镜
      backdrop-filter: blur(20rpx);
      font-weight: 600;
      font-size: 30rpx;
    }
    .tab{
      position: absolute;
      left: 0;
      top: 0;
      background: rgba(250,129,90,0.7);
      backdrop-filter: blur(20rpx);
      color: #fff;
      font-size: 22rpx;
      padding: 6rpx 14rpx;
      //左上 右上 右下  左下
      border-radius: 0 0 20rpx 0;
      //网格文字最小为12px,要想小于12px,可进行如下操作
      //缩放
      transform: scale(0.8);
      //以左上角基准偏移
      transform-origin: left top;
    }
  }
}
 

1)渲染更多标题

壁纸小程序Vue3(首页布局),壁纸小程序Vue3,小程序

index.vue

 <view class="theme">
          <common-title>
            <template #name>专题精选</template>
            <template #custom>
              <navigator url="" class="more">More+</navigator>
            </template>
          </common-title>
          <view class="content">
              <theme-item v-for="item in 8"></theme-item>
              <theme-item :isMore="true"></theme-item>
          </view>

      </view>

 them-item

 <view class="themeTtem">
      <navigator url="" class="box" v-if="!isMore">
        <image class="pic" src="https://img1.baidu.com/it/u=871832137,2572636834&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=1198" mode="aspectFill"></image>
        <view class="mask">盛世美颜</view>
        <view class="tab">3天前更新</view>
      </navigator>
      <navigator url="" class="box more" v-else>
        <image class="pic" src="https://img1.baidu.com/it/u=351608013,944758287&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=751" mode="aspectFill"></image>
        <view class="mask">
          <uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
          <view class="text">更多</view>
        </view>
      </navigator>

  </view>

.box.more{
    .mask{
      width: 100%;
      height: 100%;
      flex-direction: column;
    }
    .text{
      font-size: 28rpx;
    }
  }文章来源地址https://www.toymoban.com/news/detail-844742.html

到了这里,关于壁纸小程序Vue3(首页布局)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 微信小程序首页-----布局(详细教程赶快收藏吧)

                                                      🎬 艳艳耶✌️:个人主页                                                   🔥 个人专栏 :《Spring与Mybatis集成整合》《Vue.js使用》                                                   ⛺️ 越努力 ,越幸运

    2024年02月04日
    浏览(40)
  • 【小程序从0到1】首页布局案例的实现

    欢迎来到我的博客 📔博主是一名大学在读本科生,主要学习方向是前端。 🍭目前已经更新了 【Vue】、【React–从基础到实战】、【TypeScript】等等系列专栏 🛠目前正在学习的是🔥 R e a c t / 小程序 React/小程序 R e a c t / 小程序 🔥,中间穿插了一些基础知识的回顾 🌈博客主

    2024年02月03日
    浏览(18)
  • 微信小程序首页、界面布局、自定义顶部(示例一)

    具体界面见下图: 如需界面中引用的图片文件和更多功能,请滑动至底部查看下载链接,可下载完整版,下载后直接使用微信开发者工具打开即可,完整版功能更详细呦。当前界面的布局样式代码如下(如存在不足之处,请根据具体需求,自行修改): 1、js代码: 2、wxml代

    2024年02月12日
    浏览(30)
  • 【微信小程序(黑马程序课程)案例实现——本地生活的首页基本布局】

    一. 新建一个项目 二. 添加页面和删除页面 (1) 添加页面 ——app.json/pages中添加路径,并删除原有的路径 (2)删除页面——路径已经被删除,现在删除文件 三.设置导航栏效果 ——app.json/windows中更改 效果图: 代码如下: 四.设置tabBar效果 ——在app.json中创建tabBar(与win

    2024年04月16日
    浏览(31)
  • 微信小程序首页、界面布局、3D轮播图效果(示例二)

    使用swiper实现3D轮播图效果,自定义顶部状态栏,具体代码: 1、js代码 2、wxml代码 3、wxss代码 4、json代码 如需要下载完整版,包含监听事件、图片文件等,请前往下方链接,下载完整版,下载后直接使用微信开发者工具打开即可,下载链接为: 小程序完整版界面(示例二)

    2024年02月10日
    浏览(44)
  • 微信小程序 —— 会议OA项目首页布局与Mock数据交互

    14天阅读挑战赛 如果世界上有奇迹,那一定是努力的另一个名字。 目录 一、小程序布局 1.1 Flex布局 1.2 Flex属性   二、OA会议首页搭建 2.1 首页底部菜单 2.2 创建后端结口 2.3 Mock模拟数据 2.4 首页轮播图搭建 2.5 首页内容搭建  布局的传统解决方案,基于盒状模型,依赖 dis

    2024年02月08日
    浏览(31)
  • 微信小程序进阶——Flex弹性布局&轮播图&会议OA项目(首页)

    目录 一、Flex弹性布局 1.1 什么是Flex弹性布局 1.1.1 详解 1.1.2 图解  1.1.3 代码演示效果 1.2 Flex弹性布局的核心概念 1.3 Flex 弹性布局的常见属性 1.4 Flex弹性布局部分属性详解 1.4.1 flex-direction属性 1.4.2 flex-wrap属性 1.4.3 flex-flow属性 1.4.4 justify-content属性 1.4.5 align-items属性 1.4.6 

    2024年02月05日
    浏览(31)
  • 微信小程序之会议OA系统首页布局搭建与Mock数据交互

    目录 前言 一、Flex 布局( 分类 编程技术) 1、Flex布局是什么? 2、基本概念 3、容器的属性 3.1 flex-direction属性 3.2 flex-wrap属性 3.3 flex-flow 3.4 justify-content属性 3.5 align-items属性 3.6 align-content属性 4、项目的属性 4.1 order属性 4.2 flex-grow属性 4.3 flex-shrink属性 4.4 flex-basis属性 4.5 fl

    2024年02月08日
    浏览(36)
  • vue3框架Vite + vue Router + ts 登录后返回上一页或首页

    项目(Vue3):Vite + vue Router + ts 登录后跳转情况: ① 项目中有些页面是需要登录后才可以访问的,如果没有登录的情况下,访问该页面会自动跳转到登录页,完成登录操作后,需要再次返回到该页面 ② 如果直接访问登录页,登录后跳转到首页 访问页面时,进行限制,除了部分

    2024年02月04日
    浏览(40)
  • vue3-实战-12-管理后台-权限管理之菜单管理模块-首页-主题颜色-暗黑模式

    目录 1-列表页面功能开发 1.1-需求原型分析 1.2-接口和数据类型定义 1.3-获取服务端数据渲染页面 2-新增编辑菜单 2.1-原型需求分析 2.2-表单数据收集和页面结构开发 2.3-提交或者取消 3-删除菜单 4-首页开发 5-暗黑模式的切换和主题颜色 5.1-暗黑模式 5.2-主题颜色切换       我们

    2024年02月10日
    浏览(42)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包