【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>
相关推荐
漂流瓶jz几秒前
Polyfill方式解决前端兼容性问题:core-js包结构与各种配置策略
前端·javascript·webpack·ecmascript·babel·polyfill·core-js
Y淑滢潇潇5 分钟前
WEB 模拟学校官网
前端·css
一只小bit7 分钟前
Qt 网络:包含Udp、Tcp、Http三种协议的客户端实践手册
前端·c++·qt·页面
We་ct7 分钟前
LeetCode 238. 除了自身以外数组的乘积|最优解详解(O(n)时间+O(1)空间)
前端·算法·leetcode·typescript
AC赳赳老秦11 分钟前
低代码开发中的高效调试:基于 DeepSeek 的报错日志解析与自动修复方案生成
前端·javascript·低代码·postgresql·数据库架构·easyui·deepseek
乐迁~13 分钟前
前端PDF导出完全指南:JSPDF与HTML2Canvas深度解析与实战(上)
前端·pdf
大猫会长16 分钟前
css中,由基准色提取其他变体
前端·javascript·html
小土豆_77734 分钟前
Owl 2.8.1 核心语法速查表(新手专用)
前端·odoo/owl
firstacui40 分钟前
LVS三种模式搭建
前端·chrome
wanzhong233341 分钟前
开发日记13-响应式变量
开发语言·前端·javascript·vue