0
我使用laravel,这是我的VUE时刻JS fromnow功能VUE JS laravel
Vue.http.headers.common['X-CSRF-TOKEN'] = $("#token").attr("value");
new Vue({
el: '#notificationMenu',
data: {
patients: []
},
created: function(){
this.getPatients();
this.addUsers();
},
methods: {
getPatients: function(){
$.getJSON("{{route('api_patients')}}", function(patients){
this.patients = patients;
}.bind(this));
setTimeout(this.getPatients, 1000);
},
addUsers: function(){
// var newItem = {'name':'asdfasdf','email':'sdfsdf','password':'sdfsdf'}
// var input = this.newItem;
this.$http.get('/govaccine/addUsers', '').then((response) => {
}, (response) => {
this.formErrors = response.data;
});
}
}
});
,这里是我的观点
<li class=" notif unread" v-for="patient in patients">
<a href="#">
<div class="messageblock">
<div class="message"><strong>@{{ patient.patient_lname}} @{{ patient.patient_fname}}'s</strong> next vaccination is due on 2017-03-23 for @{{patient.vaccine_name}}
</div>
<div class="messageinfo">
<i class="icon-trophy"></i>2 hours ago
</div>
</div>
</a>
</li>
我想我在列创建查看和使用moment.js的fromnow函数,我试图寻找解决方案,但他们不适合我。
我使用了required('moment')
,但这总是我得到的错误“require is not defined”,即使通过npm install -g browserify安装了browserify。
你们有什么办法解决这个问题吗?或者其他任何方法来获得现在的时间,或者像碳排放人员那样?
您是否在使用Webpack或Browserify等构建系统? – motanelu
查看此[问题](http://stackoverflow.com/questions/34308004/moment-js-with-vuejs)并查看[vue-moment](https://github.com/brockpetrie/vue -moment)项目。 – VincenzoC
我仍然没有我现在要尝试 – Christian