Courses
Vue Foundations Vue Fullstack Vue Enterprise
Articles
Latest Topics
More
Newsletter Sponsorship Discord About
The video for this lesson is currently being updated, please read the transcript instead.
Test-driving Vue 3 > Lesson 4

Code reuse with Composition API

Let's now focus on the script section of our root component.

All the logic here is really for one thing - to manage the state of the modal.

In order to make this code resusable in other parts of the app or perhaps even in different project, we should abstract this to a seperate file.

src/App.vue

import Modal from "@/components/Modal";
export default {
  data: () => ({
   modalOpen: true  
  }),
  methods: {
   toggleModalState() { this.modalOpen = !this.modalOpen; }
  },

Back to course page

Click to load comments...

Courses
  • Vue Foundations
  • Vue Fullstack
  • Vue Enterprise
Articles
  • Latest
  • Topics
Newsletter
  • Join
  • Sponsorship
More
  • Discord
  • Vue.js jobs
  • About

Vue.js Developers © 2021. View our privacy policy .

  • RSS
  • |
  • Atom