一般用法:
App.vue中这样写
<template>
<div id="app">
<Slotuse>
<input type="text">
</Slotuse>
</div>
</template>
<script>
import Slotuse from '@/views/Slotuse.vue'
export default {
name: 'App',
components:{
Slotuse,
},
data(){
return{
}
}
}
</script>
<style>
html,
body {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0px;
margin: 0px;}
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
/* text-align: center; */
color: #2c3e50;
height: 100%;
/* margin-top: 60px; */
}
*{
margin: 0;
padding: 0;
}
</style>
Slotuse.vue中这样写
<template>
<div class="slotuse">
<slot></slot>
</div>
</template>
<script>
export default {
}
</script>
<style>
</style>
在element ui中的用法
<template>
<div>
<div class="lianxi">
<el-table :data="table2Data" style="width: 100%">
<el-table-column prop="date" label="排名" width="180" align="center">
<!-- <template slot-scope="scope">
<span
:class="scope.row.date<2?'span1':''">{
{scope.row.date}}</span>
</template>
-->
<template #default="scope">
<span :class="scope.row.date < 2 ? 'span1' : ''">{
{
scope.row.date
}}</span>
</template>
</el-table-column>
<el-table-column prop="name" label="网站" width="180">