question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Vform with Nuxt JS

See original GitHub issue

Is there any way I can use Vform with Nuxt JS as a plugin? https://nuxtjs.org/guide/plugins/

So that I don’t have to add below code on all the pages?

import { Form, HasError, AlertError } from 'vform'
Vue.component(HasError.name, HasError)
Vue.component(AlertError.name, AlertError)

I tried to create plugin by adding a vform.js file inside nuxt plugins folder

import Vue from 'vue'
import { Form, HasError, AlertError } from 'vform'

Vue.component(HasError.name, HasError)
Vue.component(AlertError.name, AlertError)

But when on any nuxt page if I do new Form() , it says “Form” is not defined.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

0reactions
ashik-ahmed-devcommented, Nov 30, 2022

import Vue from ‘vue’; import { Form, HasError, AlertError, AlertSuccess } from ‘vform’; Vue.component(HasError.name, HasError); Vue.component(AlertSuccess.name, AlertSuccess); Vue.component(AlertError.name, AlertError);

export default ({ app }, inject) => { Form.prototype.submit = function submit(method, url, config = {}) { this.startProcessing();

const data = method === 'get' ? { params: this.data() } : this.data();

return new Promise((resolve, reject) => {
  app.$axios
    .request({
      url: this.route(url),
      method,
      data,
      ...config
    })
    .then(response => {
      this.finishProcessing();
      resolve(response);
    })
    .catch(error => {
      this.busy = false;

      if (error.response) {
        this.errors.set(this.extractErrors(error.response));
      }

      reject(error);
    });
});

};

app.$vform = (…params) => new Form(…params); inject(‘vform’, (…params) => new Form(…params)); };

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intro to Nuxt 3 VeeValidate Form Validation to Your ... - YouTube
... will show you how to quickly add Nuxt 3 VeeValidate Form Validation for Vue. js to Your Nuxt 3 / Vue. js...
Read more >
vform - npm
Start using vform in your project by running `npm i vform`. There are 3 other projects in the npm registry using vform.
Read more >
Easily Handle Laravel-Vue Forms and Validation with Vform
vue-js. vform is a tiny library for Vue 2 & Vue 3 to assist with forms and validation when utilizing Laravel as a...
Read more >
Validating using vform in Vue Js - laravel - Stack Overflow
am using Vue Js and Laravel in my application. My code has products and images. I am able to upload images using axios...
Read more >
Form component — Vuetify
Vuetify is a Material Design component framework for Vue.js. ... The internal v-form component makes it easy to add validation to form ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found