1.main.js
import BsBtn from '@/components/BsBtn.vue';
Vue.component('BsBtn',BsBtn)
2.components/BsBtn.vue
<template>
<div>
<slot name="header"></slot>
<button class="btn">默认按钮</button>
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
.btn{
width: 100px;
height: 35px;
background: red;
}
</style>
3.使用
<template>
<div>
mv
<p>{{"从你的全世界路过" | format()}}</p>
<bs-btn>
<p slot="header">hello world</p> //插槽
</bs-btn>
</div>