by alevans4 · 9y ago · 0 comments
2. Again, this was basically just a choice for the example. The spinner could be defined in a module and imported/registered locally. Codepen/JSFiddle just isn't the greatest place for that kind of example.
3. Scoped slots are a way for a component to expose internal data to elements contained in a slot (content thats contained within the component but defined by it's parent). I agree, its initially one of the more confusing concepts in Vue.
<div>
<img v-if="this.status == 'pending'"
src="https://media.giphy.com/media/10kTz4r3ishQwU/giphy.gif" />
<slot v-if="this.status == 'success'" :list="this.data"></slot>
<div v-if="this.status == 'error'">{{this.error}}</div>
</div>
Then in the template the option line becomes <option v-for="option in data.list" :value="option">{{option}}</option>
Not too bad. Guess I'll have to come up with a new example of what Vue templates can't do now!