Materi
Roadmap
Proyek
Sertifikat
Skillance Code Lab
Jalankan »
Skillance Code Lab Editor
Editor
Hasil
Split
Editor Kode Sumber
Tekan
Ctrl + Enter
untuk Menjalankan
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> <style> body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: #f8fafc; color: #1e293b; padding: 24px; margin: 0; line-height: 1.6; } .vue-app-container { background: white; border-radius: 12px; padding: 24px; max-width: 520px; margin: 0 auto; box-shadow: 0 4px 15px rgba(0,0,0,0.06); border-top: 4px solid #42b883; } .vue-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9; } .vue-title { font-weight: 700; color: #0d2e5c; font-size: 16px; display: flex; align-items: center; gap: 8px; } .badge-vue { background: #42b883; color: white; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; } button { background: #42b883; color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; transition: all 0.2s; } button:hover { background: #33a06f; } input, select, textarea { padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; box-sizing: border-box; outline: none; } input:focus, select:focus, textarea:focus { border-color: #42b883; box-shadow: 0 0 0 3px rgba(66, 184, 131, 0.15); } .pill { display: inline-block; background: #e2e8f0; padding: 4px 10px; border-radius: 12px; font-size: 12px; margin: 2px; } </style> </head> <body> <div id="app" class="vue-app-container"> <div class="vue-header"> <span class="vue-title">🟢 Vue Examples</span> <span class="badge-vue">Vue 3 Live</span> </div> <p><strong>Aplikasi Todo List Interaktif:</strong></p> <div style="display:flex; gap:6px; margin-bottom:12px;"> <input type="text" v-model="tugasBaru" @keyup.enter="tambahTugas" placeholder="Tambah kegiatan baru..." style="flex:1;"> <button @click="tambahTugas">Tambah</button> </div> <ul style="padding-left:0; list-style:none; margin:0;"> <li v-for="(t, i) in list" :key="i" style="display:flex; justify-content:space-between; align-items:center; padding:8px 0; border-bottom:1px solid #f1f5f9;"> <label style="display:flex; align-items:center; gap:8px; cursor:pointer;"> <input type="checkbox" v-model="t.selesai"> <span :style="{ textDecoration: t.selesai ? 'line-through' : 'none', color: t.selesai ? '#94a3b8' : '#1e293b' }">{{ t.teks }}</span> </label> <button @click="hapusTugas(i)" style="background:#ef4444; padding:4px 8px; font-size:11px;">Hapus</button> </li> </ul> <div style="margin-top:12px; font-size:12px; color:#64748b;"> Tersisa: {{ sisaTugas }} tugas belum selesai </div> </div> <script> const { createApp, ref, reactive, computed, watch, onMounted } = Vue; createApp({ data() { return { tugasBaru: "", list: [ { teks: "Pelajari Direktif Vue 3", selesai: true }, { teks: "Uji Coba Two-Way Binding", selesai: false } ] }; }, computed: { sisaTugas() { return this.list.filter(t => !t.selesai).length; } }, methods: { tambahTugas() { if (!this.tugasBaru.trim()) return; this.list.push({ teks: this.tugasBaru.trim(), selesai: false }); this.tugasBaru = ""; }, hapusTugas(index) { this.list.splice(index, 1); } } }).mount('#app'); </script> </body> </html>
Hasil Tampilan (Browser Preview)
Muat Ulang