vue.js - 如何在 vue.js 中为 href 使用组件?
问题描述
我想将组件用作 a 标签中的 href。这是我的代码
<template>
<a v-bind:href="Library"> </a>
</template>
<script>
import Library from './Library';
export default {
name: "App",
components: {
Library,
},
}
</script>
<style>
</style>
不幸的是,我收到一条错误消息,说我没有使用库组件。有谁知道如何做到这一点?
亲切的问候埃米尔
解决方案
您不能将组件用作字符串
试试这个(例子)
<script>
import Library from './Library.js'
export default {
data() {
return {
Library: Library
}
}
}
</script>
<template>
<a :href="Library" target="_blank">test</a>
</template>
推荐阅读
- node.js - 我不知道为什么 bcrypt.compare 与散列密码不一样
- karate - Running Parallel Karate Tests with cucmber report from jar file
- angular - Property 'startWith' does not exist on type 'Observable
- sql-server - 将事务表加入开放式劳动力费率表,因为它们随时间变化(取代)
- php - 如何在 API 端点上调试 CURL 错误 56
- ios - 是否可以在未经 iOS 许可的情况下获取用户大致位置?
- react-native - CONTEXT UNDEFINED Error while using React.Context with React Navigation 5
- python - 条件文件加载和标记python
- php - 嗨,我开始使用 PHP,但遇到了初学者的错误
- java - Dagger 使用提供与创建自定义类