怎么解决vue2.6后无法使用slot插槽问题?

报错:An element cannot have multiple '<template>' elements which are distributed to the same slot

代码如下: 

<template>

  <div id="app">

     <tar-bar>

      <tar-bar-item class='tar-bar-item'>

        <template v-slot:img>

          <img src='./assets/img/tarbar/all.png'>

        </template>

        <template v-slot:div>

          <div>新建</div>

        </template>

         <template v-slot:img>

          <img src='./assets/img/tarbar/all.png'>

        </template>

        <template v-slot:div>

          <div>新建</div>

        </template>

 

      </tar-bar-item>

    </tar-bar>

  </div>

  <router-view/>

</template>

<script>

import TarBar from '@/components/tarbar/TarBar.vue'

import TarBarItem from '@/components/tarbar/TarBarItem.vue'

export default {

  name:'App',

  components:{

    TarBar,

    TarBarItem

  }

}

</script>

<style>

.tar-bar-item{

    flex:1;

    text-align:center;

    height:49px;

    font-size:14px;

}

img{

    height:24px;

    width:24px;

    margin-top:3px;

    vertical-align:middle;

    margin-bottom:2px;

}

</style>

加粗处报错

 

查看全部
weixin_43722440
__吴五五角星
2020/11/26 19:13
  • vue.js
  • 点赞
  • 收藏
  • 回答
    私信

2个回复