🏠 Home / Hub

🟢 Lesson 01 — Hello World & Data Binding

← Back to Menu  |  🏠 Hub

1. Interpolation {{ }}

{{ }} နဲ့ data ကို HTML ထဲ ထည့်ပြနိုင်တယ်

<div id="app">
  <h3>{{ message }}</h3>
  <p>Name: {{ name }}</p>
  <p>1 + 2 = {{ 1 + 2 }}</p>
  <p>{{ name.toUpperCase() }}</p>
</div>

const app = Vue.createApp({
  data() {
    return {
      message: 'Hello Vue!',
      name: 'Mg Mg'
    }
  }
})
Output:

{{ message }}

Name: {{ name }}

1 + 2 = {{ 1 + 2 }}

Upper: {{ name.toUpperCase() }}

2. v-model — Two-way Data Binding

input မှာ ရိုက်တာနဲ့ တပြိုင်နက် data ပြောင်းသွားတယ် (Real-time)

<input v-model="username" placeholder="Type your name...">
<p>Hello, {{ username }}!</p>

data() {
  return { username: '' }
}

Hello, {{ username || '(empty)' }}!

Character count: {{ username.length }}

3. v-bind — Attribute Binding

HTML attribute တွေကို data နဲ့ ချိတ်ဆက်ဖို့ v-bind သုံးတယ် (:shorthand)

<a v-bind:[dynamicHrefAttr]="link" :title="tooltip">Click me</a>
<img :src="imgUrl" :alt="imgAlt">
<p :style="{ color: textColor }">Colored Text</p>

data() {
  return {
    dynamicHrefAttr: 'href',
    link: 'https://vuejs.org',
    tooltip: 'Go to Vue.js site',
    textColor: '#42b883'
  }
}

Click me → {{ link }}

This text color comes from data!

This has a dynamic class (try changing textColor)

4. Reactive Data — Live Playground

 

Full name: {{ firstName }} {{ lastName }}

Age: → Next year: {{ age + 1 }}

v-model.number  → input ကို number အဖြစ် ယူတယ်
v-model.trim    → whitespace ဖြတ်တယ်
v-model.lazy    → blur ဖြစ်မှ update တယ်

Next: Lesson 02 → Directives

📌 Study Checklist