Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

component not rendering in production [Vue3 + Vite] #438

Open
rmarques90 opened this issue Jan 12, 2024 · 0 comments
Open

component not rendering in production [Vue3 + Vite] #438

rmarques90 opened this issue Jan 12, 2024 · 0 comments

Comments

@rmarques90
Copy link

Hi!

I'm having some trouble to render the component after building it to production. I'm using Vue3, and the latest package of the lib. I'm using VITE also.

In dev mode, is rendering normally. But, when I run the process to build, the output file does not render the component. I've checked the files, and it has been imported correctly.

My application use it in a lot of places, so I've imported in the main.js file.

My component:

<template>
    <div class="input__container">
        <vue-tel-input :inputOptions="vueTelInputOptions.inputOptions"
                      mode="national"
                      v-bind:value="modelValue"
                      v-model="internalValue"
                      :class="[ error ? 'border-2 border-red-500 rounded' : '' ]"
                      @change="onChange"
                      @validate="onValidate"
                      @blur="onBlur"
                      @focus="onFocus">
        </vue-tel-input>
        <label v-if="label" class="input__label" :class="{'input__label-focused' : focused}">{{ label }}</label>
    </div>
</template>

<script>

export default {
    name: "InputTelephone",
    props: {
        modelValue: String,
        placeholder: String,
        label: String,
    },
    emits: ['on-validate', 'update:modelValue'],
    data() {
        return {
            valid: null,
            error: false,
            internalValue: this.modelValue,
            focused: false,
            vueTelInputOptions: {
                inputOptions: {
                    placeholder: this.placeholder,
                    styleClasses: 'tel-input'
                }
            }
        };
    },
    methods: {
        onFocus() {
            this.error = false;
        },
        onBlur() {
            if (!this.valid) {
                this.error = true;
            }
        },
        onChange(phoneObject) {
            this.$emit('update:modelValue', phoneObject.number);
        },
        onValidate(event) {
            this.valid = event?.valid;

            this.$emit('on-validate', {number: event.number, valid: event.valid});

            if (this.valid) {
                this.$emit('update:modelValue', event.number);
            }
        }
    }
}
</script>

Someone had the same problem? Can I get some help, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant