Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

javascript - Missing a default scoped slot Vuetify

I am looking at the tutorials on vues page for adding tooltips. https://vuetifyjs.com/en/components/tooltips

It seems to work fine for an individual button.

However, it does not work within a v-item. I get a console message saying

'[Vuetify] v-item is missing a default scopedSlot'

<v-item v-for="foo in bars" :key=`${foo}`>
  <v-tooltip>
    <v-btn slot="activator">
      <v-icon>some-icon</v-icon>
    </v-btn>
    <span>Some tooltip text</span>
  </v-tooltip>
</v-item>

I've tried adding things to the above code like slot="activator" to v-item and slot-scope="activator" to the v-btn, but nothing seems to work quite right. Any suggestions as to what I'm doing wrong?

Running snippet added by @BoussadjraBrahim :

new Vue({
  el: '#app',
  data() {
    return {
      bars: ['a', 'b', 'c']
    }
  }

})
<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css">
<div id="app">
  <v-item-group>
    <v-container grid-list-md>
      <v-layout wrap>
        <v-flex v-for="(n,i) in bars" :key="n" xs12 md4>
          <v-item>
            <v-tooltip>
              <v-btn slot="activator">
                <v-icon>home</v-icon>
              </v-btn>
              <span>Some tooltip text {{n}}</span>
            </v-tooltip>
          </v-item>
        </v-flex>
      </v-layout>
    </v-container>
  </v-item-group>

</div>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After debugging the Code snippet i found the solution by adding slot-scope="i" to the tooltip component like <v-tooltip slot-scope="i" right> :

new Vue({
  el: '#app',
  data() {
    return {
      bars: ['home', 'event', 'info']
    }
  }

})
<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css">
<div id="app" data-app>
  <v-item-group >
    <v-container grid-list-md>
      <v-layout wrap>
        <v-flex v-for="(n,i) in bars" :key="n" xs12 md4>
          <v-item     >
            <v-tooltip   slot-scope="i" right>
              <v-btn slot="activator">
                <v-icon>{{n}}</v-icon>
              </v-btn>
              <span>{{n}}</span>
            </v-tooltip>
          </v-item>
        </v-flex>
      </v-layout>
    </v-container>
  </v-item-group>

</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...