[英]Vue.js – why is my debounce function not working with arrow function
[英]Vue.js: why is prettySchedule not a function?
给定此Vue实例:
import Vue from 'vue'
import VueResource from 'vue-resource'
import * as moment from 'moment'
var schedule = new Vue({
el: '#schedule',
template: '<table class="table"> \
<tr> \
<th>Document</th> \
<th>User</th> \
<th>Scheduled for</th> \
<th>Status</th> \
</tr> \
<tr v-for="job in jobs" :key="job.id"> \
<td>{{ job.document_id }}</td> \
<td>{{ job.user_id }}</td> \
<td>{{ this.prettySchedule(job.schedule) }}</td> \
<td>{{ job.status }}</td> \
</tr> \
</table>',
data: {
jobs: []
},
mounted() {
this.get()
},
methods: {
get: function () {
this.$http.get('/scheduled_jobs/list')
.then(response => {
this.jobs = response.body
})
},
prettySchedule: function (timeString) {
return moment(timeString).format("dddd, MMMM Do YYYY, h:mm:ss a")
}
}
})
为什么在控制台中出现此错误?
[Vue warn]: Error in render: "TypeError: this.prettySchedule is not a function"
(found in <Root>)
尝试更换
{{ this.prettySchedule(job.schedule) }}
同
{{ prettySchedule(job.schedule) }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.