Open sougiovn opened 5 years ago
Hey @gigioSouza , sadly I'm not a Vue developer so i cannot help you on this. I think best to ask on SO so you can get more audience and an appropriate answer.
Hi,
you need to register the component in your main.js file
Vue.registerElement('MaskedTextField',
() => require('nativescript-masked-text-field').MaskedTextField
);
then, use in your vue component
<MaskedTextField
v-model="cpf"
mask="999.999.999-99"
keyboardType="phone"
/>
@Gabrielr2508 It "worked", the app compiled and I'm able to use the MaskedTextField
tag/component, but the mask isn't applied.
@gigioSouza The mask works here, but v-model doesn't. Can't figure out why not. :(
@gigioSouza The mask works here, but v-model doesn't. Can't figure out why not. :(
I tried to bind the "text" property of the field and update it in the textchange event, but this caused me to not be able to change the text in the emulator
I was able to get the value using a refs property and in function it retrieves the value this way $ refs.refName.nativeView.text
Hey When I try to use this component in my NativeScript Vue app I get the error
JS ERROR TypeError: Could not load view for: maskedtextfield. TypeError: view_1.CSSType is not a function. (In 'view_1.CSSType("MaskedTextField")', 'view_1.CSSType' is undefined)
I have registered the component using
Vue.registerElement('MaskedTextField',
() => require('nativescript-masked-text-field').MaskedTextField
);
Then I just add it to the page and when I do I get the error.
<MaskedTextField
v-model="email"
mask="999.999.999-99"
keyboardType="phone"
/>
I am super new to Vue and Nativescript som I have no idea what I do wrong.
@andreaskvibydialect , make sure you are using Nativescript 4 or later. The CSSType was added relatively recent π
@andreaskvibydialect , make sure you are using Nativescript 4 or later. The CSSType was added relatively recent π
Hey Sorry for being a novice but do you mean tns-core-modules?
@andreaskvibydialect , make sure you are using Nativescript 4 or later. The CSSType was added relatively recent π
Hey Sorry for being a novice but do you mean tns-core-modules?
That is correct.
@andreaskvibydialect , make sure you are using Nativescript 4 or later. The CSSType was added relatively recent π
Hey Sorry for being a novice but do you mean tns-core-modules?
That is correct.
Hey I have version 5.2.0 when I run tns --version now and still I can't make it work in my app. Any other ideas of my registration is wrong of if it has to be locally referenced or in some way.
I have version 5.2.0 when I run tns --version now and still I can't make it work in my app. Any other ideas of my registration is wrong of if it has to be locally referenced or in some way.
Sadly I'm not a Vue developer so can't help much with the registration and other Vue stuff...
I have version 5.2.0 when I run tns --version now and still I can't make it work in my app. Any other ideas of my registration is wrong of if it has to be locally referenced or in some way.
Sadly I'm not a Vue developer so can't help much with the registration and other Vue stuff...
I understand, me neither but if you hear or see some NativeScript-Vue App that makes it possible to get this component to work please let me know.
Hey When I try to use this component in my NativeScript Vue app I get the error
JS ERROR TypeError: Could not load view for: maskedtextfield. TypeError: view_1.CSSType is not a function. (In 'view_1.CSSType("MaskedTextField")', 'view_1.CSSType' is undefined)
I have registered the component using
Vue.registerElement('MaskedTextField', () => require('nativescript-masked-text-field').MaskedTextField );
Then I just add it to the page and when I do I get the error.
<MaskedTextField v-model="email" mask="999.999.999-99" keyboardType="phone" />
I am super new to Vue and Nativescript som I have no idea what I do wrong.
Try the following: Remove the "platforms" folder and start "tns run ..." again.
I just tried the package and it worked.
I have version 5.2.0 when I run tns --version now and still I can't make it work in my app. Any other ideas of my registration is wrong of if it has to be locally referenced or in some way.
Sadly I'm not a Vue developer so can't help much with the registration and other Vue stuff...
I understand, me neither but if you hear or see some NativeScript-Vue App that makes it possible to get this component to work please let me know.
hei i got this plugin working on vue nativescript
this on my main.js
Vue.registerElement('MaskedTextField', () => require('nativescript-masked-text-field').MaskedTextField)
this on my component page
<MaskedTextField mask="999.999.999" keyboardType="phone" />
and who still use ns-vue 1.3.1 version, u should to edit your package.json
"tns-core-modules": "~4.0.0", // i changed to v 4.0.0, previously its 3.*.*
then run npm run clean
do npm install --save
finally npm run watch:android or ios
and it should work
hope that helps :)
v-model doesn't seem to work, anyone with same behaviour and how to fix it?
The textfield is not even showing up for me (tns 5.3.4)...
Same for me, it does not show up
FrΓ₯n: Jonarod notifications@github.com Svara till: PeterStaev/nativescript-masked-text-field reply@reply.github.com Datum: fredag 31 maj 2019 09:35 Till: PeterStaev/nativescript-masked-text-field nativescript-masked-text-field@noreply.github.com Kopia: Andreas Kviby Andreas.Kviby@dialect.se, Mention mention@noreply.github.com Γmne: Re: [PeterStaev/nativescript-masked-text-field] Usage with NativeScript-Vue (#29)
The textfield is not even showing up for me (tns 5.3.4)...
β You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/PeterStaev/nativescript-masked-text-field/issues/29?email_source=notifications&email_token=ALIN32VOAW7NSTIXGTXX3STPYDIKTA5CNFSM4GCWOX62YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWUOL3Q#issuecomment-497608174, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALIN32SJ3DF7QS3MBU6LUB3PYDIKTANCNFSM4GCWOX6Q.
In order for v-model to work, you will need to specify which property/event to use, like this:
Vue.registerElement(
'MaskedTextField',
() => require('nativescript-masked-text-field').MaskedTextField,
{
model: {
prop: 'text',
event: 'textChange'
}
}
);
Check this example:
https://play.nativescript.org/?template=play-vue&id=3Rac7h&v=3
@bundyo helped me out from th slack forum. Now it works. However, I found the origin of the plugin not showing was because I was actually registering the component twice: once like suggested by @bundyo :
Vue.registerElement(
'MaskedTextField',
() => require('nativescript-masked-text-field').MaskedTextField,
{
model: {
prop: 'text',
event: 'textChange'
}
}
);
but then also in my component.vue
:
DON'T DO THIS
<template>
<MaskedTextField mask="99/99" v-model="expiryDate" />
</template>
<script>
import {MaskedTextField} from "nativescript-masked-text-field" // REMOVE THIS
export default {
components: {MaskedTextField}, // REMOVE THIS
data(){
return {
expiryDate: ''
}
}
}
</script>
@Jonarod Thanks that helped once again.
Even with @bundyo answer it is still not working for me. Binding text property doesn't return anything in data. When I use with v-model it binds a whole object (not just the value) but I can't type in the field (tried with both virtual and physical keyboard).
How to add v-model to this.
I ended up using ref
and obtaining the value through this.$refs.refName.nativeView.text
, as suggested by @lennonphosfato
I ended up using the following code snippet to workaround the v-model issue:
<MaskedTextField
mask="(999) 999-9999"
keyboardType="phone"
ref="maskedtextfield"
@textChange="textFieldChange($event)"
/>
data() {
return {
val: null
}
},
methods:{
textFieldChange(args) {
this.val = args.value;
}
}
Hopefully this helps!
Hi,
I am getting this error when trying to load the app with MaskedTextField. Did the same as suggested by @bundyo.
TypeError: Class constructor TextField cannot be invoked without 'new'
I'm new to NativeScript and I'm starting with Vue, how do I use it with NativeScript-Vue?
I tested like this, but got no result