console
const statusMap = {
success: {
text: '成功',
},
running: {
text: '进行中',
},
waiting: {
text: '等待',
},
}
function getProgress(p) {
return new Promise((resolve) => {
p = Math.min(100, p + parseInt(10 * Math.random()));
setTimeout(() => {
resolve(p)
}, Math.random() * 1000);
})
}
const TaskList = Vue.component('TaskList', {
// 你的代码
})
const app = new Vue({
el: '#app',
components: { TaskList },
template: `<div class="app">
<TaskList :task="[{
status: 'waiting',
taskName: '任务1',
progress: 0,
type: 'add',
id: '1'
},{
status: 'waiting',
taskName: '任务2',
progress: 0,
type: 'del',
id: '2'
}]"></TaskList>
</div>`,
})
<div id="app"></div>