vue-插槽使用

Weather.vue:

<template>
  <div class="">
     今天的天气是
    <slot name="weather-content"></slot>
  </div>
</template>

<script>
  import has from '../directives/has'
  export default {
    directives: {
      has
    }
  }
</script>
<style scoped>

</style>

使用:

<template>


  <Weather>
    <template slot="weather-content">
      <p >晴天</p>
    </template>
  </Weather>

</template>

<script>
  import Weather from './Weather';
  export default {
    components: {
      Weather
    },
  }
</script>
<style scoped>

</style>

猜你喜欢

转载自blog.csdn.net/u013008898/article/details/113126402