<template>
<div emptyDiv>
<h3> Stages </h3>
<table :style="tableStyle">
<tbody>
<template v-for="item in jobs">
<tr>
<td v-for="stage in item.stage_exec" :style="getStyle(stage.build_id)" :title="stage.build_id" >
[[ stage.cleanDuration ]]
</td>
</tr>
</template>
</tbody>
</table>
</div>
</template>
<script>
import Vue from 'vue';
import moment from 'moment';
export default {
delimiters: [ '[[', ']]' ],
props: ['jobs'],
computed: {
tableStyle() {
return {
'background-color': '#f9f9f9',
'border-color': '#C0C0C0',
'padding': '8px',
'width': '100%',
'display': 'table',
'table-layout': 'fixed',
};
},
emptyDiv() {
return {
'display': 'contents',
};
},
},
methods: {
getStyle (name) {
switch (name) {
case 'SUCCESS':
return {
'background-color': '#dff0d8',
'padding': '10px',
'line-height': '1.42857143',
'border': '1px solid #C0C0C0',
}
case 'FAILURE':
return {
'background-color': '#f45942',
'padding': '10px',
'line-height': '1.42857143',
'border': '1px solid #C0C0C0',
}
}
},
},
filters: {
durationReadable: function(duration) {
milliseconds = parseInt((duration%1000)/100)
seconds = parseInt((duration/1000)%60)
minutes = parseInt((duration/(1000*60))%60)
if (minutes < 10) {
minutes = '0' + minutes
}
if (seconds < 10){
seconds = '0' + seconds
}
return minutes + " m " + seconds + " s " + milliseconds + ' ms'
}
},
created() {
testEndpoint = 'http://testurl'
fetch(testEndpoint)
.then(body => {
cleanStartTime = moment(body[0].time_start)
cleanEndTime = moment(body[0].time_end)
cleanDuration = this.calculateDuration(cleanStartTime, cleanEndTime)
this.job_execs.push({
'name': body[0].job.name,
'build_id': body[0].build_id,
'env': body[0].job.env,
'time_start': cleanStartTime.format('LLL'),
'time_end': cleanEndTime.format
})
})
.catch( err => {
this.isEmpty = (this.binaries.length == 0) ? true : false;
console.log('Error Fetching:', testEndpoint, err);
return { 'failure': testEndpoint, 'reason': err };
},
},
</script>
当我尝试维修组件时,它无法编译,并且不断出现无法识别的babel错误。
Unexpected token (117:2)
115 | return { 'failure': testEndpoint, 'reason': err };
116 | },
> 117 |
Unexpected token (117:2)
115 | return { 'failure': testEndpoint, 'reason': err };
116 | },
> 117 | },
| ^
118 | };
119 |
那什么是意外令牌?