<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>作用域插槽复用模板-封装for循环</title>
</head>
<body>
<div id="test">
</div>
<script>
//作用域插槽
Vue.component("ComList", {
props:["list"],
template:`
<div>
<!-- 封装for模板-->
<ul v-for="(item,index) in list">
<li :key="index">
<slot name="itFor" :it="item"></slot>
</li>
</ul>
Vue 作用域插槽复用模板-封装for循环
最新推荐文章于 2024-07-12 08:47:57 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)