We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I need to get the date change value for further work in the parent component via v-model but it doesn't get the value below is a code sample:
// components import { defineComponent, onMounted, ref, watch } from "vue"; import { Icon, useModelProxy } from "@/shared"; import AirDatepicker from 'air-datepicker'; import { InputDateProps } from "./types"; import { initDefaultProps } from "../_util";
// styles import 'air-datepicker/air-datepicker.css'; import './index.sass'
export const InputDate = defineComponent({ props: initDefaultProps(InputDateProps(), { type: 'date' }), emits: ['update:modelValue'], setup(props, { emit }) {
const model = useModelProxy() const inputDate = ref<HTMLInputElement | null>(null) const updateModel = (value:string) => { emit('update:modelValue', value); } const createDatepicker = () => { let obj = {} if (props.type === 'time') { obj = { timepicker: true, onlyTimepicker: true, position: 'bottom center' } } else { obj = { selectedDates: [new Date()], position: 'bottom center' } } return new AirDatepicker(`#${props.id}`, {...obj}); } const setAttrs = () => { const input = document.getElementById(props.id); if(props.type === 'time'){ input?.setAttribute('maxlength', '5'); input?.setAttribute('placeholder', '00:00') } else { input?.setAttribute('maxlength', '8'); input?.setAttribute('placeholder', '') } } watch(model, () => { console.log(model.value); }) onMounted(() => { createDatepicker(); setAttrs(); }) return { model, updateModel, inputDate }; }, render(props) { const { type, title, id, dateClass } = props return( <div class="container-date"> {title ? ( <span class="title-date" v-text={title} ></span> ) : ''} <label class={`label-date ${dateClass}`}> <Icon class={type} name={type} /> <input ref="inputDate" id={id} readonly class="date-field" type="text" onselect={() => this.updateModel(this.$refs.inputDate.value)} /> </label> </div> ) }
})
The text was updated successfully, but these errors were encountered:
@Danador could you please recreate working example in https://codesandbox.io
Sorry, something went wrong.
No branches or pull requests
I need to get the date change value for further work in the parent component via v-model but it doesn't get the value below is a code sample:
// components
import { defineComponent, onMounted, ref, watch } from "vue";
import { Icon, useModelProxy } from "@/shared";
import AirDatepicker from 'air-datepicker';
import { InputDateProps } from "./types";
import { initDefaultProps } from "../_util";
// styles
import 'air-datepicker/air-datepicker.css';
import './index.sass'
export const InputDate = defineComponent({
props: initDefaultProps(InputDateProps(), { type: 'date' }),
emits: ['update:modelValue'],
setup(props, { emit }) {
})
The text was updated successfully, but these errors were encountered: