Vue.js & Moment.js 输出日期渲染对象而不是日期字符串
Vue.js & Moment.js Output Date Rending Object Instead of Date String
不确定我哪里出错了,但我正在尝试在 Vue.js 组件中输出当前日期。但不是返回日期字符串(即 2017/02/02),而是返回对象的字符串 (??)。丢失...
<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>
在浏览器中,我将其视为输入值:
function boundFn(a) { var l = arguments.length; return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx) }
什么时候应该是实际的日期字符串。
您需要调用 fetchCurrentDate
函数。不引用它。
initialDate() {
return this.date ? this.date : this.fetchCurrentDate()
}
不确定我哪里出错了,但我正在尝试在 Vue.js 组件中输出当前日期。但不是返回日期字符串(即 2017/02/02),而是返回对象的字符串 (??)。丢失...
<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>
在浏览器中,我将其视为输入值:
function boundFn(a) { var l = arguments.length; return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx) }
什么时候应该是实际的日期字符串。
您需要调用 fetchCurrentDate
函数。不引用它。
initialDate() {
return this.date ? this.date : this.fetchCurrentDate()
}