鍍金池/ 問答/HTML/ vue 怎樣模擬瀏覽器控制臺輸出?

vue 怎樣模擬瀏覽器控制臺輸出?

手機端看console.log()不方便,寫了個組件直接顯示在屏幕上

<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
                });
            }
        }
    },
}

請問這樣寫合適嗎?

回答
編輯回答
敢試

常用的手機端console調(diào)試
有個叫vconsole

GitHub地址:
https://github.com/shouzijian...

你可以調(diào)整下,直接使用

2017年6月12日 10:48
編輯回答
話寡

推薦個手機端的調(diào)試神器:eruda,方便查看各種log。

經(jīng)常會在github Star和開源一些有意思的項目,歡迎follow我 ?????:https://github.com/simbawus

2017年8月2日 14:14