Can someone guide me on how to retrieve the date of the past month using Vue? This is the code I currently have:
import SomeTable from "./table/SomeTable";
export default {
name: "Cabinets",
components: {SomeTable},
data() {
return {
defaultColumns: [
'id',
'serialNumber'
],
defaultStartDate: new Date(),
defaultEndDate: new Date('2019-10-07')
}
},
props: {
startDate: {type: Date, required: false},
endDate: {type: Date, required: false},
}
}
</script>
Next, upon placing defaultStartDate
and defaultEndDate
in the SomeTable
element like this:
<some-table :start-date="defaultStartDate" :end-date="defaultEndDate" :default-columns="defaultColumns"></some-table>
The output correctly displays today's start date along with the set end date. However, when attempting something like the code snippet below:
defaultEndDate: new Date().getFullYear() + '-' + new Date().getMonth() + '-' + new Date().getDate()
I encounter errors in my local environment such as a blank screen and various issues. It seems that I'm unable to execute JavaScript in that specific context within Vue. As I am still learning about Vue and couldn't find much information through search engines, I would appreciate any advice on approaching this using either Javascript or if there's a specialized method in Vue.
EDIT: The errors I'm facing include messages like:
Error in data(): "TypeError: Date().getFullYear is not a function"
These errors arise with every JavaScript function I attempt to use inside Vue. Additionally, there's also an issue reporting:
Invalid prop: type check failed for prop "endDate". Expected Date, got String with value "2019-9-5".