How to UpperCase v-model of q-input?
-
@marconi you can do
@input="v => { contato.nome = v.toUpperCase() }"
-
@metalsadman said in How to UpperCase v-model of q-input?:
@input=“v => { contato.nome = v.toUpperCase() }”
I need aply in all inputs. What can I do ?
-
@s-molinari
I need aply in all inputs. What can I do ? -
@marconi you should make a wrapper with that setup and use it wherever, or see @s-molinari 's suggestions.
-
@metalsadman Ok, thanks for your reply, I am sorry for my english.
-
@marconi here you go using Vue.extend https://codepen.io/metalsadman/pen/eYYvNNG?editors=1010
-
@metalsadman
, this is a beautiful code. Thanks, I will add in my project
-
@metalsadman How can I registry this component global?
I added extensions.js in boot
import Quasar from 'quasar' export default ({ Vue }) => { const CustomInput = Vue.extend({ name: 'CustomInput', extends: Quasar.QInput, props: { upperCase: { type: Boolean, default: true } }, watch: { value (v) { this.upperCase && this.$emit('input', v.toUpperCase()) } } }) Vue.component(CustomInput) }
Modified quasar.config.js
boot: [ 'i18n', 'axios', 'vuelidate', 'auth', 'extensions' ],
My input is empty
-
@marconi you have the idea of how to include it, just need some changes. should be
import { QInput } from 'quasar'
, then justextends: QInput,
, also provide a name in theVue.component('CustomInput', CustomInput)
. then on your template you can just go<custom-input ... />
. you can see it here https://0ybb3.sse.codesandbox.io/form-validations/external-vuelidate the bottom input.full boot code:
import { QInput } from 'quasar' export default async ({ Vue }) => { const CustomInput = Vue.extend({ name: 'custom-input', extends: QInput, props: { upperCase: { type: Boolean, default: true } }, watch: { value(v) { this.upperCase && v && this.$emit('input', v.toUpperCase()) // added a guard for value when it's null } } }) Vue.component('CustomInput', CustomInput) }
-
@metalsadman Good Job, thanks for help me.