简体   繁体   中英

How to use components for an href in vue.js?

I want to use a component as an href in an a tag. This is my code

<template>
    <a v-bind:href="Library">  </a>
</template>

<script>
import Library from './Library';

export default {
    name: "App",
    components: {
        Library,
    },
}
</script>

<style>
    
</style>

Unfortunately, I get an error saying I didn't use the library component. Does anyone know how to do this?

Kind regards Emiel

You cannot use a component as a string

try this ( example )

<script>
import Library from './Library.js'
  export default {
    data() {
      return {
        Library: Library
      }
    }
}
</script>

<template>
  <a :href="Library" target="_blank">test</a>
</template>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM