Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay
Last active April 17, 2023 15:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JeffreyWay/7ebe043f72ddd64fb54528c74c102bc7 to your computer and use it in GitHub Desktop.
Save JeffreyWay/7ebe043f72ddd64fb54528c74c102bc7 to your computer and use it in GitHub Desktop.
Learn Vue 3: Step By Step, Episode 7, Bring it All Together - https://laracasts.com/series/learn-vue-3-step-by-step/episodes/7
import Assignments from "./Assignments.js";
export default {
components: { Assignments },
template: `
<assignments></assignments>
`,
}
export default {
template: `
<li>
<label>
{{ assignment.name }}
<input type="checkbox" v-model="assignment.complete">
</label>
</li>
`,
props: {
assignment: Object
}
}
import Assignment from "./Assignment.js";
export default {
components: { Assignment },
template: `
<section v-show="assignments.length">
<h2 class="font-bold mb-2">{{ title }}</h2>
<ul>
<assignment
v-for="assignment in assignments"
:key="assignment.id"
:assignment="assignment"
></assignment>
</ul>
</section>
`,
props: {
assignments: Array,
title: String
}
}
import AssignmentList from "./AssignmentList.js";
export default {
components: { AssignmentList },
template: `
<section class="space-y-6">
<assignment-list :assignments="filters.inProgress" title="In Progress"></assignment-list>
<assignment-list :assignments="filters.completed" title="Completed"></assignment-list>
</section>
`,
data() {
return {
assignments: [
{ name: 'Finish project', complete: false, id: 1 },
{ name: 'Read Chapter 4', complete: false, id: 2 },
{ name: 'Turn in Homework', complete: false, id: 3 },
]
}
},
computed: {
filters() {
return {
inProgress: this.assignments.filter(assignment => ! assignment.complete),
completed: this.assignments.filter(assignment => assignment.complete)
};
}
}
}
<!doctype html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<title>Episode 6: Bring it All Together</title>
<script src="https://unpkg.com/vue@3"></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="h-full grid place-items-center">
<div id="app"></div>
<script type="module">
import App from './js/components/App.js';
Vue.createApp(App).mount('#app');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment