Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!