I'm going straight to the point here, I'm creating a registration form using VUEJS. However, when I try to register the component globally it gives me error. Please bear with me I'm still new to vuejs.
when I check the console it gives me this error:
n is not a function
Thanks in advance for the help.
here's my code:
index.php file
<section id="app" class="homepage">
<div class="content">
<?php
$this->load->view($content);
?>
</div>
</section>
<script src="<?php echo base_url(); ?>/js/vue.min.js" ></script>
<script src="<?php echo base_url(); ?>/js/vue-resource.min.js" ></script>
<script src="<?php echo base_url(); ?>/js/app.js" ></script>
app.js file
Vue.component("tour-form", './components/tourForm.vue');
const app = new Vue({
el:'#app',
data(){
return{
}
}
});
tour_form.php file
<tour-form></tour-form>
When we want to globally register a component in Vue, we need to do it in this file. All you have to do is import your component, as you usually would, and then register it using app. component . import { createApp } from 'vue' import App from './App.
import Vue from "vue";import PopupWindow from "./components/PopupWindow";import App from "./App. vue";Vue. component("PopupWindow", PopupWindow); // global registration - can be used anywherenew Vue({ render: (h) => h(App),}). $mount("#app");
Single File Components(SFCs) are a style of application organization used by JavaScript UI libraries where each file represents a single component in all aspects. Typically they resemble an HTML document where you have HTML tags, Style Tag, and Script Tag all in a file.
Global registration prevents build systems from removing unused components (a.k.a "tree-shaking"). If you globally register a component but end up not using it anywhere in your app, it will still be included in the final bundle. Global registration makes dependency relationships less explicit in large applications.
Single file components are similar to regular components, but there are a few key differences which can make single file components the better tool for your project: They can be defined locally, instead of globally.
According to the official documentation, here's how we register a component globally in main.ts file if you're developing using Typescript else in main.js file: import { createApp } from 'vue'; import ComponentC from './components/ComponentC.vue'; // Usually it is App.vue inside the createApp function.
These commands are included in the development kit when Visual Basic or Visual FoxPro is installed. Depending on the application, you may have to register several OCX files this way. To register a DLL as a system global, go to the SYSTEM32 directory and locate the DLL mentioned in the error message.
Vue.component()
takes the component options ( an object {}
) as its 2nd argument
But you are passing the path of the vue component as a string.
Since you are using .vue
files you mivht be using vue-loader
to parse these files.
vue-loader
transforms the component into a plain javascript module.
So import the component and pass it as the second argument
import TourForm from './components/tourForm.vue'
Vue.component("tour-form", TourForm);
const app = new Vue({
el:'#app',
data(){
return{
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With