微信小程序-截取时间字符串(显示年月日)

主要用到:substring(0, 10)

js:

var that = this      
wx.request({
        url: 'https://xxxxx',
        headers: {
          'Content-Type': 'application/json'
        },
        method: 'GET',
        success: function(res) {
            let dataList = res.data.result.data; //获取到数据
            dataList.forEach((item) => {
              item.date = item.date.substring(0, 10); //要截取时间的字符串
            })
            that.setData({
              order: dataList //数据源
            })
        }
      }),

xml读取:


    时间:{{item.date}}

 

你可能感兴趣的:(微信小程序-截取时间字符串(显示年月日))