How do I bind events using Nuxt.js programmatically?

< template >

<div @click="loginFn">aaaa</div>

< / template >

< script >

export default {
  data () {
    return {
    }
  },
  methods: {
    loginFn () {
      // alert(1)
      console.log("hehe")
    }
  },
  mounted () {
    console.log("hehe-mounted")
  }
}

< / script >

there are two problems:
1. Does the event not work?
2. Mounted is not executed? It is executed in the created phase, so why doesn"t mounted execute it?

Aug.19,2021

mounted is only executed on the browser side, and events


nuxt.js there are only beforeCreate and created in the life cycle. If you want to obtain data asynchronously, you can use the asyncData method. It is recommended that the landlord first take a detailed look at the nuxt.js official document, ide/" rel=" nofollow noreferrer "> portal .

Menu