【Vue3.0移动端项目--旅游网】-- Loading加载和导航栏bug调试

发布于:2023-01-05 ⋅ 阅读:(415) ⋅ 点赞:(0)

多一些不为什么的坚持🤳

贤蛋 🥚大眼萌 ,一名很普通但不想普通的程序媛🙊

📝本文章收录于专栏:Vue3.0移动端项目-旅游网

第一篇:【Vue3.0移动端项目–旅游网】–项目初始化搭建

第二篇:【Vue3.0移动端项目–旅游网】–配置tabBar &首页搭建

第三篇:【Vue3.0移动端项目–旅游网】-- 城市页面搭建

第四篇:【Vue3.0移动端项目–旅游网】-- 首页日期和热门推荐处理

第五篇:【Vue3.0移动端项目–旅游网】-- 首页分类和热门精选展示

🧲 新建 loading 分支

通过 Git 管理项目,养成良好的开发习惯,可以创建分支。最后开发完可以合并分支。

  1. 创建新分支并且跳转到改分支上
git checkout -b loading
  1. 查看分支
git branch

image-20220824100606767

⛏ Loding 加载中动画

loding 是在发送网络请求等待结果的期间显示的,顾设置为全局组件

src/components/loading/loading.vue

在App.vue文件中引入该组件

image-20220824154213039

1. 引入 vant 加载中组件

image-20220824154105694

2. 设置判断 loading 显示变量

image-20220824154321415

3. 设置拦截器

image-20220824154542544

4. loading 布局设置

image-20220824154810644

image-20220824154826357

完整代码:

<template>
  <div
    class="loading"
    v-if="mainStore.isShowLoading"
  >
    <div
      class="loding-bg"
      @click="loadingClick"
    >
      <van-loading
        class="loading-moule"
        type="spinner"
        color="#38B0DE"
        size="32px"
        text-size="16px"
        vertical
      >加载中...</van-loading>
    </div>

  </div>
</template>

<script setup>
import { useMainStore } from "@/stores/modules/main";
const mainStore = useMainStore()

const loadingClick = () => {
  mainStore.isShowLoading = false
}
</script>
 
<style lang="less" scoped>
.loading {
  .loding-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.1);
  }
  .loading-moule {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    z-index: 99;
  }
}
</style>

效果:

image-20220824154934470

🛒 导航栏bug调试

bug: 地址栏输入对象的路由页面,导航栏不会触发 active 状态

image-20220824160001603

🧬 Git 管理和代码托管(github)

  1. 添加到暂存区
git add .
  1. 添加到仓库
git commit -m "loading分支"
  1. 推送代码
git push -u origin loading
  1. 将本地的 loading 分支 合并到主分支上master (注意要先切换在主分支上)
git checkout mater
  1. 分支合并
git merge loading
  1. 更新远程仓库 loading 分支
git push
  1. 删除tabbar分支
git branch -d loading

image-20220824160356205

补充:

网络数据请求地址数据

项目github 地址:https://github.com/fdfd-0313/cz-trip.git

在这里插入图片描述

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到