Import a component and its properties/methods in another component
P粉696605833
P粉696605833 2023-09-12 14:18:12
0
1
404

If I have the component LogoutButton.vue

export default {
  data() 
  {
      return {

      }
      
  },
  methods: 
  { 
    Logout()
    {
        console.log("something")
    }
  }
}
</script>
<template>
    <button @click="Logout">Logout</button>
</template>

How to use LogoutButton component in other components? I mean how to import this component and its click method in other component?

P粉696605833
P粉696605833

reply all(1)
P粉668113768
<script>
import LogoutButton from './LogoutButton.vue'

export default {
  components: {
    LogoutButton
  },
  data() 
  {
      return {

      }
      
  },
  methods: 
  { 
    // Your different methods
  }
}
</script>

<template>
  <div>
    <!-- The template from LogoutButton component will display here -->
    <LogoutButton />
  </div>
</template>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!