临时:slot作用域

  <base-layout>
    <template v-slot:header>
      <h1>Here might be a page title</h1>
    </template>
  </base-layout>

  <template>
    <ul class="list-unstyled">
      <li v-for="user in users">
        <slot name="default" :user="user">
          {{user.id}}
        </slot>
        <slot name="first" :first="user">
          {{user.firstName}}
        </slot>
        <slot name="last" :last="user">
          {{user.lastName}}
        </slot>
      </li>
    </ul>
  </template>

  <script>
    export default {
      props: ['users']
    }
  </script>

  <user-list :users="{{$users}}">
    <template #first="allsolt">
      {{allsolt.first.firstName.toUpperCase()}}
    </template>
  </user-list>

猜你喜欢

转载自www.cnblogs.com/gushixianqiancheng/p/12910443.html