【Vue 全家桶】4、Vue中的ajax(http请求方法)

目录

slot插槽

默认插槽

具名插槽

作用域插槽

html 复制代码
<!-- 子组件 template -->
<div>
  <header>
    <slot name="header"></slot> <!-- 具名插槽 -->
  </header>
  <main>
    <slot></slot> <!-- 默认插槽 -->
  </main>
  <footer>
    <slot name="footer"></slot> <!-- 具名插槽 -->
  </footer>
</div>

<!-- 父组件使用 -->
<my-component>
  <template v-slot:header>
    这里是头部内容
  </template>
  <template v-slot:default> <!-- 或者省略 :default -->
    这里是主体内容
  </template>
  <template #footer> <!-- # 是 v-slot: 的简写 -->
    这里是底部内容
  </template>
</my-component>


<!-- 子组件 template -->
<div>
  <ul>
    <li v-for="item in items" :key="item.id">
      <slot :item="item"></slot> <!-- 作用域插槽 -->
    </li>
  </ul>
</div>

<!-- 父组件使用 -->
<my-component :items="itemsList">
  <template v-slot:default="{ item }"> <!-- 解构获取 item -->
    {{ item.name }} - ${{ item.price }}
  </template>
</my-component>
相关推荐
gc_229916 小时前
Vue框架学习(1:环境搭建)
vue.js
原则猫16 小时前
UDP 到底怎么实现可靠的
前端
Java后端的Ai之路17 小时前
14、ReactJS - 路由(Router)
前端·react.js·状态模式
裕晟资质规划18 小时前
三类涉密资质延续时限差异分析:军工60日与集成印制3个月的边界
java·服务器·前端·网络·安全
ShineWinsu18 小时前
对于JavaScript:JavaScript基础语法的解析
开发语言·前端·javascript·面试·web·基础语法·循环
月夏18 小时前
Vue3 转 React:18 项对照表 + 5 个必踩的坑(附 7 天上手路线)
前端
广州华水科技18 小时前
单北斗GNSS位移监测系统的应用与维护解析
前端
梦曦i19 小时前
uni-storage 0.1.0 发布:TTL过期管理+多实例隔离
前端·storage·uni-app x
猫头_20 小时前
AI 流式传输工程指南:模型吐出半截 JSON,前端如何边收边渲染?
前端·javascript·llm
console.log('npc')20 小时前
第 1 章 项目概述与环境搭建
前端·人工智能·大模型