重置vue打印變量顯示方式

在vue使用console.log()打印變量 會有多餘咱們不指望看到的屬性
並且展開方式不友好vue

clipboard.png

因此咱們來重置一個打印方式:this

在main.js文件中添加一下代碼spa

Vue.prototype.print = (obj,type) => {
  type = type || "log";
  const log = JSON.parse(JSON.stringify(obj));
  console[type](log)
}

之後咱們打印變量就能夠直接使用prototype

this.print(obj)
//或者
this.print(obj,"error")

clipboard.png

這樣打印出來的信息就是以咱們熟悉的方式打印了code

相關文章
相關標籤/搜索