vsCode gives a warning on apparently valid code from vue.js docs

following vue.js guide for lazi-loading , when i’m writing this line of code:

import Vue from 'vue'
import Router from 'vue-router'
const Health = () => import('@/components/health')

vscode throws the following problems:

file: 'file:///c%3A/projects/vue-lazy-loading/src/router/index.js'
severity: 'Error'
message: 'Expression expected.'
at: '3,22'
source: 'js'

file: 'file:///c%3A/projects/vue-lazy-loading/src/router/index.js'
severity: 'Error'
message: 'Variable declaration expected.'
at: '3,28'
source: 'js'

visually, that’s how it looks:
enter image description here

is there something wrong with the code, or with VS-code?
what is the correct way to write it?

Source: stackoverflow-javascript

Misunderstanding lifecycle hooks VueJS

I’m starting a tuto on the framework Vue.JS.

I m using the life cycle created of the Vue. I thought that this function was called once the vue is created. But in this example,
A behavior that I do not understand.

</template> export default { name: 'game', created: function () { console.log('On Vue created') document.onkeydown = this.start }, methods: { clickOnRound: function (event) { console.log('Click') }, bonus: function (event) { console.log('Click + alt') console.log(event) }, start: function (event) { console.log('Start called') console.log(event) } } }

When I type a letter on the keyboard, the function start is called, without calling the function of created.

Here the console output:

  • On Vue created
  • Start called
  • Start called
  • Start called
  • Start called

I can t understand how the start function is called without calling each time the created function , because the start function is inside the created function.

 created: function () {
      console.log('On Vue created')
      document.onkeydown = this.start

Source: stackoverflow-javascript