Vue中把从后端取出的时间进行截取

  未截取前

  截取后

  方法:

</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);
        });
    }
  }
}

 

posted @ 2019-04-18 15:12  Cy_0710  阅读(4808)  评论(2)    收藏  举报