0

I want to register vForm in index.js globally in Vue js 3 but not work, while using vuejs 2 it work like Vue.component(Form) in Vue Vue js 3 how to define once and usable in all window or component, this bellow code not working. Thanks for your comment and soon response.

import { Form, HasError, AlertError } from 'vform';
app.use(Form);
app.use(HasError);
app.use(AlertError)

2 Answers 2

0

Well, it works the same in Vue 3 - but instead of using the global Vue you use your app:

import { createApp } from 'vue';
import App from './App.vue';
import router from './router'; 
import { Form, HasError, AlertError } from 'vform';

const myApp = createApp(App);
myApp.use(router);
myApp.component('v-form', Form);
myApp.component('has-error', HasError);
myApp.component('alert-error', AlertError);
myApp.mount('#app'); 
Sign up to request clarification or add additional context in comments.

4 Comments

I got error as the bellow code. warning in ./src/main.js export 'HasError' (imported as 'HasError') was not found in 'vform' (possible exports: Errors, Form, default) warning in ./src/main.js export 'AlertError' (imported as 'AlertError') was not found in 'vform' (possible exports: Errors, Form, default)
And now what? The error message is pretty clear - how do you plan to resolve it?
Did you get a solution for this finally?
Check whether your vform package actually exports a HasError component.
0

This what i will do in Vue 3

import App from "@/components/App";
import Form from "vform";
import { HasError, AlertError } from "vform/src/components/bootstrap5";

HasError and AlertError can also be imported from vform/src/components/bootstrap4

const app = createApp(App);
window.Form = Form;
app.component("has-error", HasError);
app.component("alert-error", AlertError);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.