【アウトプット㊼】-Vue- v-bind:classの使い方

文字を赤くする
▼HTML

<div id="app">
  <p :class="error_class">こんにちは</p>
</div>

※値にマスタッシュ構文は使えない
NG  <p :class="{{error_class}}">こんにちは</p>

▼CSS

.error {
   color: red;
}

▼vue.js

let app = new Vue({
    el: "#app",
    data: {
        error_class: "error"
    }    
 });

▼表示結果

無題


この記事が気に入ったらサポートをしてみませんか?