Giter Club home page Giter Club logo

Comments (12)

wotamann avatar wotamann commented on June 16, 2024 3

in version 0.2.4 any global registered component is possible. It is not longer necessary to prefix the component name with 'v-'

from vuetify-form-base.

wotamann avatar wotamann commented on June 16, 2024 1

Maybe this can help!

Create component 'customcomponent.vue'

<!--  /component/customcomponent.vue -->
<template>
  <div >
    <h4>Custom Control Object</h4>
    <v-text-field v-model="value.a" @input="$emit('input', value)" label="A"></v-text-field>
    <v-text-field v-model="value.b" @input="$emit('input', value)" label="B"></v-text-field>
    <v-btn small color="grey" dark  @click="clear">Clear both</v-btn>    
  </div>
</template>

<script>
export default {
  props: ['type','value'],    
  methods:{
    clear(){
      this.value.a = null
      this.value.b = null
      this.$emit('input', this.value)
    }    
  }
}
</script>

And then register this component globally in main.js.
IMPORTANT: You must prepend component name with 'v-' like 'v-customname'

Vue.component('v-custom1', () => import('@/components/customcomponent.vue') )

Now you can use this Component with
model: { mycustom: { a:'AAA', b:'BBB' }, schema: { mycustom: { type: 'custom1' } }.

from vuetify-form-base.

OdiljonQurbon avatar OdiljonQurbon commented on June 16, 2024

I'm also interested in this. Thanks.

from vuetify-form-base.

miguelrk avatar miguelrk commented on June 16, 2024

Hey! I've been enjoying vuetify-form-base a lot! It really rocks!

After using it for a while now, I am starting to need the possibility of creating custom components/formfields. This could be similar to how vue-form-generator does it.

Anyways, is this feature currently planned? I would also be very interested!

from vuetify-form-base.

miguelrk avatar miguelrk commented on June 16, 2024

Thanks for the quick respnse! That is just what I needed, as flexible as possible! Thanks a lot! I will give it a try

from vuetify-form-base.

joxper avatar joxper commented on June 16, 2024

@wotamann I have tried with version 0.2.4 but still is looking for a 'v-' component:
image

Is there a specific way to use it in the schema?
this is my schema:

  profileSchema = {
    phone: {
      type: 'VuetifyPhoneInput',
      label: 'Phone',
      class: 'py-0 px-1',
      outlined: true,
    },
  };

thanks

from vuetify-form-base.

wotamann avatar wotamann commented on June 16, 2024

Lookup for a 'v-'component signals, that no GLOBAL registered component was found.

I don't know how you registered your component. Because HTML is case-insensitive maybe your uppercase name is the problem (see Vue-Discussion here)

// Global definition in 'main.js'
// works
Vue.component('custom-basic-a', () => import('@/components/customcomponent-basic.vue') )
Vue.component('customBasicB', () => import('@/components/customcomponent-basic.vue') )
// doesn't work
Vue.component('custom-basic-c', () => import('@/components/customcomponent-basic.vue') )
// works
schema: { custom1: { type: 'custom-basic-a', label:'Component - Basic' }  }
schema: { custom1: { type: 'customBasicB', label:'Component - Basic' }  }
// doesn't work
schema: { custom1: { type: 'customBasicC', label:'Component - Basic' }  }

from vuetify-form-base.

joxper avatar joxper commented on June 16, 2024

I am registering it as a plugin, because it comes from an external library

import Vue from 'vue'
import VueTelInputVuetify from 'vue-tel-input-vuetify'

Vue.use(VueTelInputVuetify)

and in the VueTelInputVuetify setup is registering the component as:

Vue.component('vue-tel-input-vuetify', VueTelInputVuetify);

I tried like like:

  profileSchema = {
    phone: {
      type: 'VuetifyPhoneInput',
      label: 'Phone',
      class: 'py-0 px-1',
      outlined: true,
    },
  };

and

  profileSchema = {
    phone: {
      type: 'vue-tel-input-vuetify',
      label: 'Phone',
      class: 'py-0 px-1',
      outlined: true,
    },
  };

Still have the same error, where its trying to get the v- component
image

thanks

from vuetify-form-base.

joxper avatar joxper commented on June 16, 2024

Only when registered like this it works

Vue.component('v-vue-tel-input-vuetify', VueTelInputVuetify);

so custom components without the v- wont work

from vuetify-form-base.

wotamann avatar wotamann commented on June 16, 2024

registration is checked in mapTypeToComponent using registered components from Vue.options.components

try to log Vue.options.components after registration to see if there is a vue-tel-input-vuetify component.

// MAP TYPE TO COMPONENT
    mapTypeToComponent(type) {
      // merge global registered components into typeToComponent Object
      const allTypeComponents = { ...typeToComponent, ...Vue.options.components}
      // const typeToComponent -> maps type to according v-component 
      // ie. schema:{ type:'password', ... } to specific vuetify-control or default to v-text-field'

      return allTypeComponents[type] 
          ? allTypeComponents[type] 
          : `v-${type}` // add v- to schema type
    },

from vuetify-form-base.

wotamann avatar wotamann commented on June 16, 2024

this setup worked for me

main.js

import Vue from 'vue'
import App from '@/App.vue'
import VueTelInputVuetify from 'vue-tel-input-vuetify'
import vuetify from '@/plugins/vuetify'

Vue.use(VueTelInputVuetify, {
  vuetify,
});

console.log('VueTelInputVuetify', VueTelInputVuetify);

console.log('Components', Vue.options.components)

new Vue({
  el: '#main',
  vuetify,
  render: h => h(App)
})

use component in vue file


schema: {  myTel: { type:'vue-tel-input-vuetify' }

from vuetify-form-base.

joxper avatar joxper commented on June 16, 2024

Hi @wotamann thanks for taking your time,
I log the components, seems like the component is present but still is looking for the v- type, but is OK I will use it with the v- and will solve the problem.
image

thanks for the awesome library

from vuetify-form-base.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.