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