반응형
<template>
<div>
<h1>Hello Vue!</h1>
<h2 class="line-through">line-through</h2>
<h2 v-bind:class="textDecroation" class="text-red">line-through</h2>
<h2 :class="isDone === true ? 'line-through' : 'highlight'">
line-through
</h2>
<h2
:class="{
highlight: isDone === false,
'text-red': username === 'scalper',
}"
>
Object형태의 동적 클래스
</h2>
<h2
:class="[
isDone === true ? 'line-through' : 'highlight',
username === 'scalper' ? 'text-red' : 'text-green',
]"
>
Array 형태의 동적 클래스 부여
</h2>
</div>
</template>
<script>
export default {
name: "App",
data() {
return {
username: "scaalper",
isDone: true,
textDecroation: "line-through",
};
},
};
</script>
<style>
.text-red {
color: red;
}
.text-green {
color: green;
}
.highlight {
font-weight: bold;
background: pink;
}
.line-through {
text-decoration: line-through;
}
</style>
반응형
'Web > Vue' 카테고리의 다른 글
[Vue] 메서드 (0) | 2022.06.24 |
---|---|
[Vue] 조건부 리스트 렌더링 (0) | 2022.06.24 |
[Vue] 리스트 렌더링 (0) | 2022.06.23 |
[Vue] 조건부 렌더링 (0) | 2022.06.23 |
[Vue] v-if v-show 차이 (0) | 2022.06.23 |