1

Not sure where I'm going wrong here, but I'm trying to output current date in a Vue.js component. But instead of returning a date string (i.e. 2017/02/02) it's returning a string of the object (??). Lost...

<template>
    <div>
        <input type="text" :value="initialDate">
    </div>
</template>

<script>

    export default {
        props: ['date', 'user'],

        computed: {
            initialDate() {
                return this.date ? this.date : this.fetchCurrentDate
            }
        },

        methods: {
            fetchCurrentDate() {
                return window.moment()
            },
        }
    }
</script>

In the browser, I'm seeing this as the input value:

function boundFn(a) { var l = arguments.length; return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx) }

When it should be an actual date string.

1 Answer 1

1

You need to call the fetchCurrentDate function. Not reference it.

initialDate() {
      return this.date ? this.date : this.fetchCurrentDate()
}
Sign up to request clarification or add additional context in comments.

2 Comments

God damn. FML...always the little things. Thanks for your help :) #TimeForBreak
@MikeBarwick Been there :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.