I'm trying to show dates diffForHumans based on this guide: https://www.talvbansal.me/blog/human-readable-dates-with-dayjs-in-vue-js/
So I'm trying to load DayJS as component in my VueJS app this way:
<script src="{{ asset('/vendor/vuejs/vue.js') }}" type="text/javascript"></script>
<script src="{{ asset('/vendor/vue-dayjs/dayjs.min.js') }}"></script>
<script type="text/javascript">
Vue.component("dayjs", dayjs);
Vue.filter('formatDateDiffForHumans', function(value){
if (!value) return null;
return dayjs(value).fromNow();
});
var app = new Vue({
el:'#vue_app',
data:{
......
}
});
</script>
.....
<span>@{{ t.object.created_at | formatDateDiffForHumans }}</span>
Then I'm getting this error:
[Vue warn]: Error in render: "TypeError: dayjs(...).fromNow is not a function"
Am I doing something wrong?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…