【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>
相关推荐
Hacker_seagull1 分钟前
Chrome安装代理插件ZeroOmega(保姆级别)
前端·chrome
石小石Orz5 分钟前
因为没有使用路由懒加载,产生了一个难以寻找的bug
前端
Mintopia5 分钟前
Three.js 力导向图:让数据跳起优雅的华尔兹
前端·javascript·three.js
墨渊君20 分钟前
React Native 跨平台组件库实践: GlueStack UI 上手指南
前端
晓得迷路了28 分钟前
栗子前端技术周刊第 84 期 - Vite v7.0 beta、Vitest 3.2、Astro 5.9...
前端·javascript·vite
独立开阀者_FwtCoder31 分钟前
最全301/302重定向指南:从SEO到实战,一篇就够了
前端·javascript·vue.js
Moment40 分钟前
给大家推荐一个超好用的 Marsview 低代码平台 🤩🤩🤩
前端·javascript·github
小满zs44 分钟前
Zustand 第三章(状态简化)
前端·react.js
普宁彭于晏1 小时前
元素水平垂直居中的方法
前端·css·笔记·css3
恋猫de小郭1 小时前
为什么跨平台框架可以适配鸿蒙,它们的技术原理是什么?
android·前端·flutter