vue slots, `slot` and `slot-scope` are deprecated

I found an error when writing a project using a slot:

`slot` attributes are deprecated vue/no-deprecated-slot-attribute

According to the information, the slot and slot-scope in the official document have been deprecated

The original method of use:

  <div class="content">
    <slot name="contrite"></slot>
  </div>

  <h1 slot="contrite" class="title">内容</h1>

渲染结果:

  <div class="content">
    <h1 class="title">Content</h1>
  </div>

How to use it now:

  <div class="content">
    <slot name="contrite"></slot>
  </div>

   <template v-slot:contrite>
        内容
   </template>

可简写为:

   <template #contrite>
        content
   </template>

rendering results consistent

Note: v-slot can only be added to a <template> (with one exception), unlike the deprecated slot feature.
Exception: Component tags can only be used as templates for slots when only the default slot is provided. This way we can use v-slot directly on the component.

Guess you like

Origin blog.csdn.net/qq_40999917/article/details/129734505