It looks like there are a few issues with the code provided. Here's a revised version that should work:
In your hello-world.vue file:
<template>
<modal name="hello-world">
<p>hello, world!</p>
</modal>
</template>
<script>
export default {
name: "hello-world",
methods: {
show() {
this.$modal.show("hello-world");
},
hide() {
this.$modal.hide("hello-world");
},
},
};
</script>
In your supplier/listing.js file:
import HelloWorld from "../app-components/hello-world.vue";
Vue.component("supplier-listing", {
mixins: [AppListing],
components: {
"whatsapp-link": WhatsAppLink,
"call-link": CallLink,
"hello-world": HelloWorld,
},
methods: {
showHelloWorld() {
this.$refs.helloWorld.show();
},
hideHelloWorld() {
this.$refs.helloWorld.hide();
},
},
});
In your supplier/index.blade.php file:
<button @click="showHelloWorld()">Show Modal</button>
<hello-world ref="helloWorld"></hello-world>
Explanation:
- In the hello-world.vue file, I removed the
dataproperty and moved thenameproperty to the component options object. I also wrapped the "hello, world!" text in a<p>tag for clarity. - In the supplier/listing.js file, I imported the hello-world component and added
showHelloWorldandhideHelloWorldmethods that call the corresponding methods in the hello-world component using a ref. - In the supplier/index.blade.php file, I added a ref to the hello-world component and changed the
@clickevent to call theshowHelloWorldmethod.
Note that you'll need to make sure that the Vue instance is properly set up and that the $modal plugin is installed. You can refer to the Vue documentation and the Laravel documentation for more information on how to do this.