Vue中把从后端取出的时间进行截取
未截取前
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。截取后
方法:
</div>{{times}}</div>
export default{
data() { return { // getTime储存从服务器请求回来的数据 getTime:"" } }, computed:{ times(){ var s = this.getTime; // 将截取后的时间return出来 return s.substring(0,10) } }, mounted() { this.getData(); }, methods: { getData() { // 向服务器请求数据 this.$http.get("/Movie/InfoMovieID="+this.$route.params.id) .then(res => { console.log(res.data); // 将请求回来的时间存到 getTime中 this.getTime = res.data.ReleaseTime }) .catch(err => { console.log(err); }); } } }

更多精彩