1
我试图使用Vue公司的scoped slots:为什么我的scoped插槽不显示任何内容?
App.vue:
<template>
<div id="app">
<b-grid>
<slot name="col" :col="2">
<p>Some test</p>
</slot>
</b-grid>
</div>
</template>
BGrid.vue
<template>
<div class="b-grid">
<div class="container">
<div class="row">
<template slot="col" scope="props">
<div :class="'col' + props.col">This is a column</div>
</template>
</div>
</div>
</div>
</template>
然而,槽显示在页面上。控制台没有错误:
<div id="app">
<div class="b-grid">
<div class="container">
<div class="row"></div>
</div>
</div>
</div>
我在做什么错了?
注意:我正在使用Vue 2.3.4
噢,谢谢......但我希望':class =“'col'+ props.col”'在BGrid组件内。你知道我该怎么做?就像我的原始代码一样。 – alex
在那里没有意义,因为该插槽没有引用作用域的'props'变量。如果你只是想从父模板添加一个动态类,只需将它添加到元素,如'
我看到谢谢。所以没有办法将动态数据添加到组件内的插槽中。 – alex