vue.js css last-child 効かない


vue.jsでlast-childが効かないぞ?

結論

hoge.vue

<style>

    .kudamono .kudamono-item {
        background-color: blue;
    }

    .kudamono .kudamono-item:last-child {
        background-color: red !important;
    }

</style>




<div class="kudamono">
    <div v-for="(v,key) in menu" class="kudamono-item">
        {{v.body}}
    </div>
</div>


これで効く。

  • v-forの外側にclassを作る
  • 上記でv-forのdivを囲い設定する

といった感じです