728x90

🌲 Interpolations
보간법
🌳문자열
데이터 바인딩의 가장 기본 형태는 {{ Mustache }} - 이중 중괄호 구문 기법을 사용한다.
🌲 Directives
v- 형식을 사용하는 특별한 속성
🌳v-on
<template>
<button
v-on:click="msg"> // @click="msg"
</button>
</template>
🌳v-once
<template>
<h1
v-once
@click="add">
{{ msg }}
</h1>
</template>
<script>
export default {
data() {
return {
msg: 'Hello world!'
}
},
methods: {
add() {
this.msg += '!'
}
}
}
</script>
🌳원시 HTML
<template>
<h1 v-html="msg"></h1>
</template>
<script>
export default {
data() {
return {
msg: '<div style="color:red;">Hello world!</div>'
}
},
methods: {
add() {
this.msg += '!'
}
}
}
</script>
🌳v-bind
<template>
<h1 v-bind:class="msg">
{{ msg }}
</h1>
</template>
<script>
export default {
data() {
return {
msg: 'active'
}
}
}
</script>
<style scoped>
.active {
color: blue;
}
</style>
🌳동적전달인자
<template>
<h1 :[attr]="msg">
{{ msg }}
</h1>
</template>
<script>
export default {
data() {
return {
msg: 'active',
attr: 'class'
}
}
}
</script>
🌳보간법 디렉티브
v-once | 일회성 보간으로 데이터가 변경되어도 갱신되지 않음 |
v-html | html이 동작하도록 |
v-if | 불리언을 판단하여 삽입하거나 제거 |
v-bind | v-bind:id 또는 :id |
v-on | v-on:click 또는 @click / DOM이벤트를 수신하는 디렉티브 |
[이름] | 동적 전달 인자, 디렉티브의 인자로 사용할 때 문법 |
공식문서
템플릿 문법 | Vue.js
템플릿 문법 Vue.js는 렌더링 된 DOM을 컴포넌트 인스턴스의 데이터에 선언적으로 바인딩할 수 있는 HTML 기반 템플릿 구문을 사용합니다. 모든 Vue.js 템플릿은 스펙을 호환하는 브라우저 및 HTML 파
v3.vuejs-korea.org
728x90
'FE' 카테고리의 다른 글
Vue.js class, style binding (0) | 2021.12.11 |
---|---|
Vue.js Watch/Computed Caching - Computed VS Methods (0) | 2021.12.11 |
Vuejs 컴포넌트 연결하는 방법 (0) | 2021.12.11 |
Vue.js설치방법과 webpack template에서 사용법 (0) | 2021.12.06 |
Vue.js ESLint 문법검사 구성 (0) | 2021.12.06 |