Javascript 力矩js fromnow函数到vue js laravel
我用的是拉威尔,这是我的vueJavascript 力矩js fromnow函数到vue js laravel,javascript,laravel,vue.js,momentjs,Javascript,Laravel,Vue.js,Momentjs,我用的是拉威尔,这是我的vue Vue.http.headers.common['X-CSRF-TOKEN'] = $("#token").attr("value"); new Vue({ el: '#notificationMenu', data: { patients: [] }, created: function(){ this.g
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>
我想在视图中创建我的“at”列,并使用moment.js的fromnow函数,我试图寻找解决方案,但它们对我不起作用
我使用了required('moment')
,但即使通过npm install-g browserify安装了browserify,这始终是我得到的错误“require未定义”
你们有办法解决这个问题吗?或者任何其他获取fromnow时间的方法,或者类似于碳元素的difffromhuman?模板中的上下文只包含在Vue数据上声明的变量。你的选择是:
最后一个是推荐的路线。您使用的是像Webpack或Browserify这样的构建系统吗?看看这个,看看这个项目。我还是不打算尝试now@motanelu尝试使用browserify,但仍然不起作用