【发布时间】:2017-07-07 03:29:06
【问题描述】:
我正在使用 laravel,这是我的 vue
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。
你们有什么办法解决这个问题吗?或任何其他方法来获取从现在开始的时间或像碳的 difffromhuman 一样?
【问题讨论】:
-
你在使用像 Webpack 或 Browserify 这样的构建系统吗?
-
查看此question 并查看vue-moment 项目。
-
我还是没有我现在要试试
-
@motanelu 尝试使用 browserify 但仍然无法正常工作
标签: javascript laravel vue.js momentjs