黑马程序员前端 Vue3 小兔鲜电商项目——(三)Layout 首页页面布局

news2024/9/30 17:32:56

文章目录

    • 组件结构快速搭建
      • 首页组件结构
      • Nav 组件
      • Header 组件
      • Footer 组件
      • index.vue 中添加组件
    • 字体图标渲染
    • 一级导航渲染
      • 封装接口函数
      • 渲染数据
    • 吸顶导航交互实现
      • 安装 VueUser 插件
      • 组件静态结构
      • 添加组件
      • 实现吸顶交互
    • Pinia优化重复请求

组件结构快速搭建

首页组件结构

页面效果如下:

image-20230620214009351

可以将页面分为四个部分:Nav、Header、二级页面、Footer。

分别在下面创建三个vue文件:

image-20230620212614426

Nav 组件

添加代码:

<script setup>

</script>

<template>
    <nav class="app-topnav">
        <div class="container">
            <ul>
                <template v-if="true">
                    <li><a href="javascript:;"><i class=" iconfont icon-user"></i>周杰伦</a></li>
                    <li>
                        <el-popconfirm title="确认退出吗?" confirm-button-text="确认" cancel-button-text="取消">
                            <template #reference>
                                <a href="javascript:;">退出登录</a>
                            </template>
                        </el-popconfirm>
                    </li>
                    <li><a href="javascript:;">我的订单</a></li>
                    <li><a href="javascript:;">会员中心</a></li>
                </template>
                <template v-else>
                    <li><a href="javascript:;">请先登录</a></li>
                    <li><a href="javascript:;">帮助中心</a></li>
                    <li><a href="javascript:;">关于我们</a></li>
                </template>
            </ul>
        </div>
    </nav>
</template>


<style scoped lang="scss">
.app-topnav {
    background: #333;

    ul {
        display: flex;
        height: 53px;
        justify-content: flex-end;
        align-items: center;

        li {
            a {
                padding: 0 15px;
                color: #cdcdcd;
                line-height: 1;
                display: inline-block;

                i {
                    font-size: 14px;
                    margin-right: 2px;
                }

                &:hover {
                    color: $xtxColor;
                }
            }

            ~li {
                a {
                    border-left: 2px solid #666;
                }
            }
        }
    }
}
</style>

Header 组件

添加代码:

<script setup>

</script>

<template>
    <header class='app-header'>
        <div class="container">
            <h1 class="logo">
                <RouterLink to="/">小兔鲜</RouterLink>
            </h1>
            <ul class="app-header-nav">
                <li class="home">
                    <RouterLink to="/">首页</RouterLink>
                </li>
                <li>
                    <RouterLink to="/">居家</RouterLink>
                </li>
                <li>
                    <RouterLink to="/">美食</RouterLink>
                </li>
                <li>
                    <RouterLink to="/">服饰</RouterLink>
                </li>
            </ul>
            <div class="search">
                <i class="iconfont icon-search"></i>
                <input type="text" placeholder="搜一搜">
            </div>
            <!-- 头部购物车 -->

        </div>
    </header>
</template>


<style scoped lang='scss'>
.app-header {
    background: #fff;

    .container {
        display: flex;
        align-items: center;
    }

    .logo {
        width: 200px;

        a {
            display: block;
            height: 132px;
            width: 100%;
            text-indent: -9999px;
            background: url('@/assets/images/logo.png') no-repeat center 18px / contain;
        }
    }

    .app-header-nav {
        width: 820px;
        display: flex;
        padding-left: 40px;
        position: relative;
        z-index: 998;

        li {
            margin-right: 40px;
            width: 38px;
            text-align: center;

            a {
                font-size: 16px;
                line-height: 32px;
                height: 32px;
                display: inline-block;

                &:hover {
                    color: $xtxColor;
                    border-bottom: 1px solid $xtxColor;
                }
            }

            .active {
                color: $xtxColor;
                border-bottom: 1px solid $xtxColor;
            }
        }
    }

    .search {
        width: 170px;
        height: 32px;
        position: relative;
        border-bottom: 1px solid #e7e7e7;
        line-height: 32px;

        .icon-search {
            font-size: 18px;
            margin-left: 5px;
        }

        input {
            width: 140px;
            padding-left: 5px;
            color: #666;
        }
    }

    .cart {
        width: 50px;

        .curr {
            height: 32px;
            line-height: 32px;
            text-align: center;
            position: relative;
            display: block;

            .icon-cart {
                font-size: 22px;
            }

            em {
                font-style: normal;
                position: absolute;
                right: 0;
                top: 0;
                padding: 1px 6px;
                line-height: 1;
                background: $helpColor;
                color: #fff;
                font-size: 12px;
                border-radius: 10px;
                font-family: Arial;
            }
        }
    }
}</style>

Footer 组件

添加代码:

<template>
    <footer class="app_footer">
        <!-- 联系我们 -->
        <div class="contact">
            <div class="container">
                <dl>
                    <dt>客户服务</dt>
                    <dd><i class="iconfont icon-kefu"></i> 在线客服</dd>
                    <dd><i class="iconfont icon-question"></i> 问题反馈</dd>
                </dl>
                <dl>
                    <dt>关注我们</dt>
                    <dd><i class="iconfont icon-weixin"></i> 公众号</dd>
                    <dd><i class="iconfont icon-weibo"></i> 微博</dd>
                </dl>
                <dl>
                    <dt>下载APP</dt>
                    <dd class="qrcode"><img src="@/assets/images/qrcode.jpg" /></dd>
                    <dd class="download">
                        <span>扫描二维码</span>
                        <span>立马下载APP</span>
                        <a href="javascript:;">下载页面</a>
                    </dd>
                </dl>
                <dl>
                    <dt>服务热线</dt>
                    <dd class="hotline">400-0000-000 <small>周一至周日 8:00-18:00</small></dd>
                </dl>
            </div>
        </div>
        <!-- 其它 -->
        <div class="extra">
            <div class="container">
                <div class="slogan">
                    <a href="javascript:;">
                        <i class="iconfont icon-footer01"></i>
                        <span>价格亲民</span>
                    </a>
                    <a href="javascript:;">
                        <i class="iconfont icon-footer02"></i>
                        <span>物流快捷</span>
                    </a>
                    <a href="javascript:;">
                        <i class="iconfont icon-footer03"></i>
                        <span>品质新鲜</span>
                    </a>
                </div>
                <!-- 版权信息 -->
                <div class="copyright">
                    <p>
                        <a href="javascript:;">关于我们</a>
                        <a href="javascript:;">帮助中心</a>
                        <a href="javascript:;">售后服务</a>
                        <a href="javascript:;">配送与验收</a>
                        <a href="javascript:;">商务合作</a>
                        <a href="javascript:;">搜索推荐</a>
                        <a href="javascript:;">友情链接</a>
                    </p>
                    <p>CopyRight © 小兔鲜儿</p>
                </div>
            </div>
        </div>
    </footer>
</template>
  
<style scoped lang='scss'>
.app_footer {
    overflow: hidden;
    background-color: #f5f5f5;
    padding-top: 20px;

    .contact {
        background: #fff;

        .container {
            padding: 60px 0 40px 25px;
            display: flex;
        }

        dl {
            height: 190px;
            text-align: center;
            padding: 0 72px;
            border-right: 1px solid #f2f2f2;
            color: #999;

            &:first-child {
                padding-left: 0;
            }

            &:last-child {
                border-right: none;
                padding-right: 0;
            }
        }

        dt {
            line-height: 1;
            font-size: 18px;
        }

        dd {
            margin: 36px 12px 0 0;
            float: left;
            width: 92px;
            height: 92px;
            padding-top: 10px;
            border: 1px solid #ededed;

            .iconfont {
                font-size: 36px;
                display: block;
                color: #666;
            }

            &:hover {
                .iconfont {
                    color: $xtxColor;
                }
            }

            &:last-child {
                margin-right: 0;
            }
        }

        .qrcode {
            width: 92px;
            height: 92px;
            padding: 7px;
            border: 1px solid #ededed;
        }

        .download {
            padding-top: 5px;
            font-size: 14px;
            width: auto;
            height: auto;
            border: none;

            span {
                display: block;
            }

            a {
                display: block;
                line-height: 1;
                padding: 10px 25px;
                margin-top: 5px;
                color: #fff;
                border-radius: 2px;
                background-color: $xtxColor;
            }
        }

        .hotline {
            padding-top: 20px;
            font-size: 22px;
            color: #666;
            width: auto;
            height: auto;
            border: none;

            small {
                display: block;
                font-size: 15px;
                color: #999;
            }
        }
    }

    .extra {
        background-color: #333;
    }

    .slogan {
        height: 178px;
        line-height: 58px;
        padding: 60px 100px;
        border-bottom: 1px solid #434343;
        display: flex;
        justify-content: space-between;

        a {
            height: 58px;
            line-height: 58px;
            color: #fff;
            font-size: 28px;

            i {
                font-size: 50px;
                vertical-align: middle;
                margin-right: 10px;
                font-weight: 100;
            }

            span {
                vertical-align: middle;
                text-shadow: 0 0 1px #333;
            }
        }
    }

    .copyright {
        height: 170px;
        padding-top: 40px;
        text-align: center;
        color: #999;
        font-size: 15px;

        p {
            line-height: 1;
            margin-bottom: 20px;
        }

        a {
            color: #999;
            line-height: 1;
            padding: 0 10px;
            border-right: 1px solid #999;

            &:last-child {
                border-right: none;
            }
        }
    }
}
</style>

index.vue 中添加组件

<script setup>
import LayoutNav from './components/LayoutNav.vue'
import LayoutHeader from './components/LayoutHeader.vue'
import LayoutFooter from './components/LayoutFooter.vue'
</script>

<template>
  <LayoutNav />
  <LayoutHeader />
  <RouterView />
  <LayoutFooter />
</template>

字体图标渲染

字体图标采用的是阿里的字体图标库,样式文件已经准备好,在 index.html文件中引入即可

<head>
  <meta charset="UTF-8">
  <link rel="icon" href="/favicon.ico">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>小兔鲜儿</title>
  <!--阿里图标-->
  <link rel="stylesheet" href="//at.alicdn.com/t/font_2143783_iq6z4ey5vu.css">
</head>

一级导航渲染

导航栏效果如图显示:

image.png

封装接口函数

在 src/apis 目录下创建 layout.js 文件:

image-20230620214648527

在其中编写函数使用 Axios 访问导航栏接口 Api:

import http from '@/utils/http'

export function getCategoryAPI () {
  return http({
    url: 'home/category/head'
  })

渲染数据

在 LayoutHeader.vue 文件的 <script> 标签中引入 getCategoryAPI() 方法获取分类信息,将返回的数据存储到 categoryList 数组中:

<script setup>
  //导入方法
  import { getCategoryAPI } from '@/apis/layout'
  import { onMounted, ref } from 'vue'
  //获取分类信息,将返回的数据存储到 categoryList 数组
  const categoryList = ref([])
  const getCategory = async() => {
    const res = await getCategoryAPI();
    console.log(res);
    categoryList.value = res.result;
  }
  //实例被挂载后调用
  onMounted(() => {
    getCategory()
  })
</script>

并在 html 中使用 v-for 标签进行遍历输出。

<ul class="app-header-nav">
  <li class="home" v-for="item in categoryList" :key="item.id">
    <RouterLink to="/">{{ item.name }}</RouterLink>
  </li>
</ul>

吸顶导航交互实现

要求:浏览器在上下滚动的过程中,如果距离顶部的滚动距离大于78印X,吸顶导航显示,小于78px隐藏

安装 VueUser 插件

VueUse 是一个基于 Composition API 的实用程序函数集合。

npm i @vueuse/core

组件静态结构

<script setup>

</script>

<template>
  <div class="app-header-sticky">
    <div class="container">
      <RouterLink class="logo" to="/" />
      <!-- 导航区域 -->
      <ul class="app-header-nav ">
        <li class="home">
          <RouterLink to="/">首页</RouterLink>
        </li>
        <li>
          <RouterLink to="/">居家</RouterLink>
        </li>
        <li>
          <RouterLink to="/">美食</RouterLink>
        </li>
        <li>
          <RouterLink to="/">服饰</RouterLink>
        </li>
        <li>
          <RouterLink to="/">母婴</RouterLink>
        </li>
        <li>
          <RouterLink to="/">个护</RouterLink>
        </li>
        <li>
          <RouterLink to="/">严选</RouterLink>
        </li>
        <li>
          <RouterLink to="/">数码</RouterLink>
        </li>
        <li>
          <RouterLink to="/">运动</RouterLink>
        </li>
        <li>
          <RouterLink to="/">杂项</RouterLink>
        </li>
      </ul>

      <div class="right">
        <RouterLink to="/">品牌</RouterLink>
        <RouterLink to="/">专题</RouterLink>
      </div>
    </div>
  </div>
</template>


<style scoped lang='scss'>
.app-header-sticky {
  width: 100%;
  height: 80px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 999;
  background-color: #fff;
  border-bottom: 1px solid #e4e4e4;
  // 此处为关键样式!!!
  // 状态一:往上平移自身高度 + 完全透明
  transform: translateY(-100%);
  opacity: 0;

  // 状态二:移除平移 + 完全不透明
  &.show {
    transition: all 0.3s linear;
    transform: none;
    opacity: 1;
  }

  .container {
    display: flex;
    align-items: center;
  }

  .logo {
    width: 200px;
    height: 80px;
    background: url("@/assets/images/logo.png") no-repeat right 2px;
    background-size: 160px auto;
  }

  .right {
    width: 220px;
    display: flex;
    text-align: center;
    padding-left: 40px;
    border-left: 2px solid $xtxColor;

    a {
      width: 38px;
      margin-right: 40px;
      font-size: 16px;
      line-height: 1;

      &:hover {
        color: $xtxColor;
      }
    }
  }
}

.app-header-nav {
  width: 820px;
  display: flex;
  padding-left: 40px;
  position: relative;
  z-index: 998;

  li {
    margin-right: 40px;
    width: 38px;
    text-align: center;

    a {
      font-size: 16px;
      line-height: 32px;
      height: 32px;
      display: inline-block;

      &:hover {
        color: $xtxColor;
        border-bottom: 1px solid $xtxColor;
      }
    }

    .active {
      color: $xtxColor;
      border-bottom: 1px solid $xtxColor;
    }
  }
}
</style>

添加组件

在 index.vue 中添加吸顶导航栏组件:

<script setup>
import LayoutNav from './components/LayoutNav.vue'
import LayoutHeader from './components/LayoutHeader.vue'
import LayoutFooter from './components/LayoutFooter.vue'
import LayoutFixed from '@/views/Layout/components/LayoutFixed.vue'
</script>

<template>
		// 吸顶导航栏组件
    <LayoutFixed />
    <LayoutNav />
    <LayoutHeader />
    <RouterView />
    <LayoutFooter />
</template>

实现吸顶交互

核心逻辑:根据滚动距离判断当前show类名是否显示,大于78显示,小于78,不显示

<script setup>
// vueUse
import { useScroll } from '@vueuse/core'
const { y } = useScroll(window)
</script>

<template>
  <div class="app-header-sticky" :class="{ show: y > 78 }">
    <!-- 省略部分代码 -->
  </div>
</template>

Pinia优化重复请求

吸顶导航栏和一级导航栏获取数据的逻辑是一模一样的,但是一样的数据会调用两次接口,所以使用 Pinia 优化重复请求。

在 stores 目录下创建 category.js 文件:

import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getCategoryAPI } from '@/apis/layout'

export const useCategoryStore = defineStore('category', () => {
    // 导航列表数据管理
    //state 导航列表数据
    const categoryList = ref([])

    // action 获取导航数据的方法
    const getCategory = async () => {
        const res = await getCategoryAPI();
        console.log(res);
        categoryList.value = res.result;
    }

    return {
        categoryList, getCategory
    }
})

在 Layout/index.vue 中调用 useCategoryStore 获取数据的方法:

import { useCategoryStore } from '@/stores/category'
import { onMounted } from 'vue'

const categoryStore = useCategoryStore()
onMounted(() => {
    categoryStore.getCategory()
})

之后在 LayoutHeader.vue 中导入方法直接访问 useCategoryStore 中存储数据的 categoryList 即可。同理,LayoutFixed.vue 也是如此:

//导入方法
import { useCategoryStore } from '@/stores/category'
const categoryStore = useCategoryStore()
<ul class="app-header-nav">
  <li class="home" v-for="item in categoryStore.categoryList" :key="item.id">
    <RouterLink to="/">{{ item.name }}</RouterLink>
  </li>
</ul>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/670383.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

字节跳动的项目经理,是什么神仙存在?

早上好&#xff0c;我是老原。 要是说起项目经理的待遇天花板&#xff0c;你觉得会是什么样的&#xff1f; 在2022年&#xff0c;虽然很多互联网大厂都在大裁员&#xff0c;同时也刺激了更多人想进大厂的心。 就从项目经理这个岗位来看&#xff0c;你说大小厂的工作内容差距…

Win11的两个实用技巧系列之找不到项目的文件如何删除、无法用蓝牙耳机的多种解决办法

Win11 新预览版怎么恢复文件管理器经典功能? Win11 新预览版怎么恢复文件管理器经典功能&#xff1f;Win11最新版去掉了文件管理器经典功能&#xff0c;该怎么操作呢&#xff1f;下面我们就来看看详细的恢复方法 微软在日前发布的 Win11 Dev Build 23481 预览版更新中&#x…

建筑中的智能照明系统

【摘要】&#xff1a;建筑智能照明工程中智能照明控制系统发展迅速&#xff0c;具有舒适性和节能性两方面优势。智能照明控制系统已经处于模块化高速发展阶段&#xff0c;如今更好的控制方案成为制约系统发展的瓶颈。文章在研究了国内外智能照明系统的基础上&#xff0c;从照明…

Java 结合中文分词库 jieba 统计一堆文本中各个词语的出现次数【代码记录】

文章目录 1、需求2、代码3、结果 1、需求 2、代码 package com.zibo.main;import com.huaban.analysis.jieba.JiebaSegmenter;import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.HashMap; import java.util.List; imp…

Picker, ColorPicker, DatePicker 的使用

1. Picker 选择器的使用 1.1 实现 /// 选择器 struct PickerBootcamp: View {State var selection: String "Most Recent"let filterOptions:[String] ["Most Recent", "Most Popular", "Most Liked"]init(){UISegmentedControl.ap…

Python基础(16)——Python集合(set)

Python基础&#xff08;16&#xff09;——Python集合&#xff08;set&#xff09; 文章目录 Python基础&#xff08;16&#xff09;——Python集合&#xff08;set&#xff09;目标一. 创建集合二. 集合常见操作方法2.1 增加数据2.2 删除数据2.3 查找数据 三. 总结 目标 创建…

Python基础(17)——Python运算符、公共方法、类型转换

Python基础&#xff08;17&#xff09;——Python运算符、公共方法、类型转换 文章目录 Python基础&#xff08;17&#xff09;——Python运算符、公共方法、类型转换目标一. 运算符1.1 1.2 *1.3 in或not in 二. 公共方法2.1 len()2.2 del()2.3 max()2.4 min()2.5 range()2.6 e…

4个重要的云安全方向

导语 伴随着云计算的不断发展和成熟&#xff0c;云安全越来越受到重视&#xff0c;每一年云安全都有不同的重点话题值得关注&#xff0c;今天我们一起来看看2023非常重要4个云安全话题 云攻击路径发现和威胁建模 随着攻击面的扩大&#xff0c;企业云安全的复杂性也会增加。为您…

一文搞懂 MySQL 中的常用函数及用法

0️⃣前言 MySQL是一种常用的关系型数据库管理系统&#xff0c;它提供了许多内置函数来处理数据。本文将介绍MySQL中的各种常用函数&#xff0c;包括字符串函数、日期函数、数学函数、聚合函数等。 文章目录 0️⃣前言1️⃣字符串函数1.1CONCAT函数1.2SUBSTRING函数1.3REPLACE函…

测试用例常用方法和选择原则

目录 前言&#xff1a; 一、等价类划分法 等价类思考步骤&#xff1a; 二、边界值 边界值的方法小结&#xff1a; 三、因果图法 因果图中的符号&#xff1a; 利用因果导出测试用例需要经过以下几个步骤&#xff1a; 四、判定表法 组成部分&#xff1a; 书写步骤&#xff1a; 五…

神经网络笔记

多分类问题 Softmax 高级优化算法 Adam Algorithm Intuition 每个参数有不同的学习率 卷积层 每个神经元只看前一层输入的一部分 原因&#xff1a; 1.更快的计算 2.需要更少的训练数据&#xff08;不容易过度拟合&#xff09; 模型评估 成本函数 分类 训练集用来训练…

【Python】数据库(创建库 访问 连接 创建表 编辑记录 案例:客户管理实现)

文章目录 * 库表与管理1.访问数据库1.1 连接与创建数据库1.2 创建表1.3 编辑表记录1.3.1 添加记录1.3.2 修改记录1.3.3 返回所有记录1.3.4 删除记录1.3.5 查询记录 1.4 案例&#xff1a;客户管理 SQLite 实现 * 库表与管理 1.访问数据库 SQLite 是 Python 自带的数据库管理模…

SpringBoot 如何使用 Spring Cloud Stream 处理事件

SpringBoot 如何使用 Spring Cloud Stream 处理事件 在分布式系统中&#xff0c;事件驱动架构&#xff08;Event-Driven Architecture&#xff0c;EDA&#xff09;已经成为一种非常流行的架构模式。事件驱动架构将系统中的各个组件连接在一起&#xff0c;以便它们可以相互协作…

【深度学习】5-4 与学习相关的技巧 - 正则化解决过拟合(权值衰减,Dropout)

机器学习的问题中&#xff0c;过拟合是一个很常见的问题。过拟合指的是只能拟合训练数据&#xff0c;但不能很好地拟合不包含在训练数据中的其他数据的状态。机器学习的目标是提高泛化能力&#xff0c;即便是没有包含在训练数据里的未观测数据也希望模型可以进行正确的识别。 …

皓文电子 | 智能制造领先企业的安全服务经验分享

皓文电子是一家为客户提供设计、生产、销售高端开关电源及各类功率变换产品的国家级高新技术企业&#xff0c;是国内智能制造领域的代表企业。其核心产品能与国际主流电源厂商竞争&#xff0c;达到国内外领先水平&#xff0c;并在国家多个重点项目中批量生产装备。 遭遇安全事件…

2023年湖北孝感初、中级工程师职称报名条件和要求是什么?启程别

2023年湖北孝感初、中级工程师职称报名条件和要求是什么&#xff1f;启程别 初级职称对于找工作很有帮助。现在&#xff0c;学历越来越高&#xff0c;仅有学历已经不能满足应聘需求。初级职称的获得并不难&#xff0c;有了职称也会让自己在找工作时更有竞争力。威信公号搜一下启…

2023年最新智能优化算法之——IBI逻辑优化算法(IBL),附MATLAB代码

今天给大家带来一个有意思的智能优化算法&#xff0c;IBL算法。 先说效果&#xff1a;在CEC2005函数集测试&#xff0c;基本上毫无压力&#xff0c;把把都能预测的很准确&#xff0c;而且速度极快。大家可以自行尝试哈。 为啥说这个算法有意思呢&#xff0c;大家看IBL的英文全…

史上最大图灵测试实验完成150万人类参与1000万次对话,判断对面是人还是AI

本文 介绍 了AI 21实验室推出了一个好玩的社交图灵游戏——「人类还是机器人&#xff1f;」 【导读】这个「人类还是AI?」的游戏一经推出&#xff0c;就被广大网友们玩疯了&#xff01;如今全世界已有150万人参与&#xff0c;网友们大方分享自己鉴AI的秘诀。 历上规模最大的…

解决:torch.cuda.is_available()一直返回False,显卡是NVIDA GeForce MX250

目录 1. 背景2. 发现问题根源3. 解决问题 1. 背景 AI时代了&#xff0c;之前一直不怎么用到的小米笔记本Pro的 NVIDA GeForce MX250独显&#xff0c;就想着让它发挥余热&#xff0c;免得买了这么多年&#xff0c;一直闲置&#xff0c;浪费。 无脑按照chatGPT给的例子&#x…

为什么Django要引入CSRF令牌?答:主要是为了防止跨站伪造请求攻击,那么什么是跨站伪造请求攻击呢?

“CSRF”的英文全称是&#xff1a;“Cross-Site Request Forgery”&#xff0c;翻译过来就是&#xff1a;“跨站请求伪造”。 那么什么是跨站伪造请求攻击呢&#xff1f;看下面这张图就够了。 注意&#xff1a;看上面这张图请按图中标注的1到6的顺序阅读。 Django通过引入CS…