Comments (12)
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.
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.
I'm also interested in this. Thanks.
from vuetify-form-base.
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.
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.
@wotamann I have tried with version 0.2.4 but still is looking for a 'v-' component:
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.
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.
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
thanks
from vuetify-form-base.
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.
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.
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.
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.
thanks for the awesome library
from vuetify-form-base.
Related Issues (20)
- Clearing date picker doesn't clear the model value
- Failed to resolve directive: click-outside HOT 2
- How can I wrap the inputs in my own element?
- Vue3 + Vuetify3 HOT 5
- Typescript support HOT 1
- Why package.json scripts is empty?
- v-form-base not rendered in production mode HOT 2
- `pattern` doesn't allow for regex flags HOT 1
- Feature Request: Can you please add a "Description" field made of append icon with tooltip?
- Using axios api calls
- Custom Component With Slots
- Problem with label string
- Which Json Schema Library shoud I choose? HOT 1
- Hidden groups in an array
- Object Bindings
- How to bind properties? HOT 1
- How to disable the default no-gutters?
- Checkbox returns NULL when it should return FALSE HOT 3
- How to use v-form-base in a v-for loop? HOT 2
- Cant Render custom components HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuetify-form-base.