【发布时间】:2018-10-05 15:03:47
【问题描述】:
{"status":true,"data":[{"_id":"5addb7cbcd79850454bceb9f","no":12123,"orDate":"2010-01-01T00:00:00.000Z","oldness":"5"},{"_id":"5ae02a26de15e934ac70ee8f","no":11223,"orDate":"2004-01-01T00:00:00.000Z","oldness":"5"},{"_id":"5ae02a26de257934ac70ee8f","no":12311,"orDate":"1994-01-01T00:00:00.000Z","oldness":"5"}]}
这是我的 json 响应。我只需要在 vue js html 中从 orDate 打印年份。
我怎样才能做到这一点。
我的html代码是
<div id="app">
<div v-for="aln in data">
{{aln._id}}
{{aln.no}}
{{aln.orDate}}
</div>
</div>
我或日期,我只需要打印从日期开始的年份。如果日期是 2010-01-01T00:00:00.000Z,我只需要打印 2010
我的vue js代码是
app = new Vue({
el: "#iapp",
data: {
data:[],
},
mounted: function() {
var vm = this;
$.ajax({
url: "http://localhost:4000/get/l/",
method: "GET",
dataType: "JSON",
success: function(e) {
if (e.status == 1) {
vm.data = e.data;
console.log(vm.data);
}
},
});
},
})
【问题讨论】:
标签: javascript jquery html vue.js vue-component