Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

185
Vistas
How can I call functions at href in vue.js?

When I run this source then it showed me just

[Kakao is not defined] https://i.stack.imgur.com/UA7VI.png

My sources are like this

in 『nuxt.config.js』

export default {
  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    script: [
      { src: 'https://developers.kakao.com/sdk/js/kakao.js'},
    ]
  },
}

in 『./pages/login.vue』

<template>
   <a :href="loginWithKakao()">
     <img
       src="https://k.kakaocdn.net/14/dn/btqCn0WEmI3/nijroPfbpCa4at5EIsjyf0/o.jpg"
       width="222"
     />
   </a>          
</template>
<script>

export default {
  data() {
    return {
      visible: true,
      account: '',
      password: '',
    }
  },
  computed: {
    ...mapState('store', { logo: (state) => state.logo }),
  },
  methods: {
    loginWithKakao() {
      Kakao.Auth.login({
        success: function (response) {
          // console.log("Kakao.Auth.login - success response ->", response);
          Kakao.API.request({
            url: '/v2/user/me',
            success: function (response) {
              console.log(response)
            },
            fail: function (error) {
              console.log(error)
            },
          })
        },
        fail: function (error) {
          console.log(error)
        },
      })
    },       
  },
  mounted(){
    // Initialize the SDK. Please set the JavaScript key for the app you want to use.
    Kakao.init('JavaScript key');

    // Determines whether to initialize the SDK.
    console.log('Kakao.isInitialized() >>', Kakao.isInitialized());
  },
}
</script>

When I used this in html, it worked

<a id="custom-login-btn" href="javascript:loginWithKakao()">
  <img
    src="https://k.kakaocdn.net/14/dn/btqCn0WEmI3/nijroPfbpCa4at5EIsjyf0/o.jpg"
    width="222"
  />
</a>

As I know, we can use href="javascript:your_function()" in html as :href="your_function()" in Vue.js

Or are there some ways something others?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Why not use a Button instead of an <a> tag, as it is obviously not a link? However, either way you should just add a click handler to invoke the function:

<a @click="loginWithKakao()">
  <img
  
  src="https://k.kakaocdn.net/14/dn/btqCn0WEmI3/nijroPfbpCa4at5EIsjyf0/o.jpg"
    width="222"
  />
</a> 
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda