it is not convenient for the mobile phone to watch console.log (), so write a component to display it directly on the screen
<template>
<ul class="log-screen">
<li v-for="(log, index) in dataLog">{{log.text}}<i v-if="log.repeat">{{log.repeat}}</i></li>
</ul>
</template>
<script>
export default {
name: "log-screen",
data() {
return {
lastMsg:"",
dataLog:[{
text:"",
repeat:2
}]
};
},
methods: {
log(l){
if (lastMsg === l) {
let idx = this.dataLog.length-1;
this.dataLog[idx].repeat += 1;
}else{
this.dataLog.push({
text:l,
repeat:0
});
}
}
},
}
is it appropriate to write in this way?