vue各种过滤

// 时间过滤

formatTime = function (now, timestamp) {

var date = new Date(timestamp)
if (date.getFullYear() === now.getFullYear()) {
    if (date.getMonth() === now.getMonth()) {
        if (date.getDate() === now.getDate()) {
            return timestamp.getHours() + ':' + timestamp.getMinutes()
        } else {
            return timestamp.getDate() +' '+ timestamp.getHours() + ':' + timestamp.getMinutes()
        }
    } else {
        return timestamp.getMonth() + 1 + '-' + timestamp.getDate()
    }
} else {
    return timestamp.getFullYear() + '-' + (timestamp.getMonth() + 1) + '-' + timestamp.getDate()
}

}

formatFullTime = function (timestamp) {
    var timeObj = new Date(timestamp)
    return timeObj.getFullYear() + '-' + (timeObj.getMonth() + 1) + timeObj.getDate()
}

 

//过滤掉标签

filText(str){

                str = str.replace(/]*?>[\s\S]*?<\/script>/ig, ''); //去掉

你可能感兴趣的:(vue)