Search code examples
console.logvue-cli

How can I make console.log() work in a Vue-cli app?


I am trying to add a console.log() call in my vue-cli app to support debugging. Here's an excerpt from my template

      <v-btn v-on:click.native="console.log('start button clicked')" 
      color="primary rounded-pill">
        Start
      </v-btn>

However, when I run the app on localhost, I get the following message in the console:

vue.runtime.esm.js?2b0e:619 [Vue warn]: Property or method "console" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.

I reviewed How enable console log in VUE-CLI during development, but it didn't seem to apply to my case, as I am not using eslint, and there is no eslintConfig section in my package.json file.

Any idea what else could be going on?


Solution

    1. Try adding "this" so it would look like: this.console.log()
    2. just make a vue method and call it on click