07-01-vue-basic

by ZooeyLai

HTML

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<div id="app">
  <div class="note">
    <h3 class="title">
      <!-- 請顯示第一個項目的標題 -->
      {{notes[0].title}}
    </h3>
    <p class="content">
      <!-- 請顯示第一個項目的內容 -->
      {{notes[0].content}}
    </p>
  </div>
  <div class="note">
    <h3 class="title">
      <!-- 請顯示第二個項目的標題 -->
       {{notes[1].title}}
    </h3>
    <p class="content">
      <!-- 請顯示第二個項目的內容 -->
      {{notes[1].content}}
    </p>
  </div>
  <div class="note">
    <h3 class="title">
      <!-- 請顯示第三個項目的標題 -->
       {{notes[2].title}}
    </h3>
    <p class="content">
      <!-- 請顯示第三個項目的內容 -->
      {{notes[2].content}}
    </p>
  </div>
</div>

CSS

*,
*::after,
*::before {
 padding: 0px;
 margin: 0px;
 box-sizing: border-box;
 line-height: 1.5;
 font-size: 1rem;
}
.note{
  padding: 1rem;
  border: 1px solid #D8DAE0;
  border-radius: 0.5rem;
  margin: 1rem;
}

JavaScript

const { createApp } = Vue

createApp({
  data() {
    return {
      notes: [{
          title: "春節行程安排",
          content: "吃飽睡,睡飽吃",
          color: "red",
        },
        {
          title: "工作待辦事項",
          content: "詢問各家廠商報價",
          color: "green",
        },
        {
          title: "運動健身計畫",
          content: "每天早上六點去健身",
          color: "blue",
        },
      ]
    }
  }
}).mount('#app')