Unable to retrieve the Date Range Picker value in Vuejs

I am new to VueJS and I am having trouble retrieving the value of the selected date range. When I click the button, the console prints out a value of null. Can someone please assist me with this issue?

Below is the code snippet:

App.vue

<template>
  <div id="app">
    <VueRangedatePicker v-model="datepicker"></VueRangedatePicker>
    <button class="button" @click="showdata()" value="Test">Normal</button>
  </div>
</template>

<script>
import VueRangedatePicker from "vue-rangedate-picker";
export default {
  name: "App",
  components: {
    VueRangedatePicker
  },
  data() {
    return {
      datepicker: null
    };
  },
  methods: {
    showdata() {
      console.log("DATE PICKER", this.datepicker);
    }
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

To view the full code, visit here.

Answer №1

In order for v-model to function properly within a component, it must possess a property named value and emit an input event.

VueRangedatePicker does not have this particular property or event. Instead, it emits a selected event upon updates. You can detect this event by using the @selected directive. Here is an example:

<VueRangedatePicker @selected="updateDatePicker"></VueRangedatePicker>
  methods: {
    showdata() {
      console.log("DATE PICKER", this.datepicker);
      console.log("start: " + this.datepicker.start);
      console.log("end: " + this.datepicker.end);
    },
    updateDatePicker(value) {
      console.log("updating datepicker value");
      this.datepicker = value;
    }

You can view the updated code here.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Avoiding Vue Select from automatically highlighting the initial option: tips and tricks

Currently utilizing Vue Select as a typeahead feature that communicates with the server via AJAX. By default, the first option from the server response is highlighted like this: https://i.stack.imgur.com/jL6s0.png However, I prefer it to function simila ...

A guide on enabling the second selection to fill data based on the chosen option from the

Whenever I make a selection in the first dropdown, the second dropdown should dynamically update based on that option. However, although the data is successfully populated in the first dropdown, the second dropdown still does not respond. I suspect that th ...

Using VueMultiselect with Vue 3: A guide for beginners

I'm currently experimenting with the vue multiselect component, but when I include it in the template, I am encountering a series of warnings and errors. <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email ...

Scaling Vuetify icons dimensions

During the development of an app using Vuetify, I encountered challenges in changing the default colors set by Vuetify. After some trial and error, I came across a solution on: https://github.com/vuetifyjs/vuetify/issues/299 The solution involved adding ...

Issues with running Vue commands have been reported in Git-Bash, however they seem to work fine in

Whenever I check the version of Vue in my Terminus bash by running vue --version, here's the output I receive: $ vue -v /bin/sh: /Users/kirkb/AppData/Local/Yarn/bin/../Data/global/node_modules/.bin/vue: No such file or directory In PowerShell, when I ...

Error message: Insufficient credentials to access DRF system

For some reason, my app is no longer allowing users to log in after making changes to their profile. I have a nested User serializer with the profile serializer fields (one-to-one relationship) using Djoser for the urls. When attempting to update the user ...

CSS mismatch detected between production and development modes

Currently, I am utilizing the Vuetify framework coupled with custom CSS for a project developed using a webpack template. During development mode, my custom CSS modifications are successfully applied to HTML elements; however, in Production mode, these cha ...

When executing `npm run start`, a blank page appears exclusively on the server

I recently set up a Vue landing page on my Mac. In the terminal, I navigated to the folder and executed "npm install" and "npm run dev", which ran without any issues. However, when trying to do the same on a managed server, I encountered challenges with t ...

The Vue2 transition feature is not functioning properly when adding new elements

Trying to implement a transition-group for animating list items upon deletion. The animation works smoothly when I remove an item from the list. However, adding a new list results in a console error message: [Vue warn]: <transition-group> children m ...

"Embracing Micro-frontends: Building dynamic web applications using a variety of frontend

I am currently facing a software architecture dilemma. My extensive monolithic web application is built using PHP and backbone js, but I am eager to integrate a new front-end framework like react/vue. The question arises about the best approach to tackle t ...

v-treeview component triggering method execution twice upon input

I'm facing an issue with my Vue component that contains a treeview. Upon selecting a node, the goal is to update an array and display the checkbox as selected. However, I'm encountering a problem where if I select elements from one folder in the ...

continuously repeating css text animation

How do I create an animation loop that slides infinitely, repeating non-stop in full screen without breaking at 'hello5'? I want to display 3 rows of the same item from my items array. Not sure which CSS is causing the issue. The result I am loo ...

Tips for specifying the return type of app.mount()

Can I specify the return value type of app.mount()? I have a component and I want to create Multiple application instances. However, when I try to use the return value of mount() to update variables associated with the component, TypeScript shows an error ...

Error message received when attempting to remove object in Laravel and Vue framework

My aim is to delete a record in Vue successfully. Although the deletion of records works, I am encountering an error message in the console. 405 (Method Not Allowed) The error appears in the network tab as: "exception": "Symfony\Component\ ...

What is the best way to tailor specific text in d3.js?

I need assistance with customizing the appearance of an asterisk added to the end of a template literal in d3js. I want to be able to independently adjust the size and color of the asterisk regardless of the variable it's attached to. Below is the cod ...

Is there a way to access the body html element within a template in vue.js?

I'm struggling to add styles to the body element of my HTML page. It seems like I can't access it directly from the template because there's another body element nested inside the main body. Even when I try to change the style using JavaScri ...

Tips for retrieving console data in VueJS Data

Is there a way to review data from a form component in the console without vue taking any action? I need to receive external data and fill in the fields accordingly. I attempted to set a value using document.getElementsByName("nfe.codigo")[0].value = "000 ...

Methods to retrieve an array's value list dynamically using the 'id' in Vuejs

**User.vue** <template> <div> <div v-for="list in lists" :key="list.id">{{ list.val }} {{ list.kk }}</div> </div> </template> <script> import { datalist } from "./datalist"; export default { name: "User ...

Error: Unable to call dispatch method on this.$store object

I'm diving into Vue and hitting a wall with this error message. TypeError: this.$store.dipatch is not a function I've set up the store.js file and am attempting to call actions from within a vue file. I've scoured the internet for answers ...

The issue with Bootstrap Vue scrollspy arises when trying to apply it to dynamic data. Upon closer inspection, it becomes evident that the elements are activating and highlighting one by

In my application built with Vue, content is displayed based on the component type (Header, Text, Image) in a JSON file. I am looking to implement scroll spy functionality specifically for the Header component containing headings. I have attempted to use ...