[英]moment js fromnow function to vue js laravel
我正在使用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')
但這始終是我通過“ npm install -g browserify”安裝browserify時得到的“未定義要求”的錯誤。
你們有什么辦法解決這個問題嗎? 還是任何其他方法來獲取從現在開始的時間,或者像碳從人類身上擴散出去?
模板中的上下文只會包含在Vue數據上聲明的變量。 您的選擇是:
最后一條是推薦路線。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.