I need to use the DateFNS in a CodePen but can't get it to work. Error:
"[Vue warn]: Error in data(): 'ReferenceError: dateFns is not defined' (found in < Root>)"
Here is my example CodePen: https://codepen.io/anon/pen/eKqxmd
<div id="app">
<v-app id="inspire">
<v-layout>
<v-flex xs12 sm6 offset-sm3>
<v-card>
<v-card-title primary-title>
<div>
<h3 class="headline mb-0">DATE {{ todaysDateMin }}</h3>
</div>
</v-card-title>
</v-card>
</v-flex>
</v-layout>
</v-app>
</div>
import { format } from 'date-fns'
new Vue({
el: '#app',
data () {
return {
todaysDateMin: dateFns.format(new Date(), '[Today is a] dddd')
}
}
})
In CodePen go to Settings -> JavaScript
and in the External Resource search type date-fns
and select from the dropdown list.
Then to call it you need to append dateFns.
, just like you are already doing.
dateFns.format(new Date(), '[Today is a] dddd')
And remove the import statement