我制作了一个循环,该循环通过从JSON文件中获取信息来生成翻转卡。翻转卡时,会有一个按钮。如何做到这一点,以便当我按下按钮时将其重定向到产品的Amazon页面,但它会从我的JSON文件中获取链接? 我尝试做这样的事情,但是它加载到了页面上并且没有重定向。
<a data-fancybox="images" v-bind:href="book.detail">
<button class="fancybox" v-on:click="book.detail">
Show More
</button>
</a>
JSON文件
"books": [
{
"cover": "https://images-na.ssl-images-amazon.com/images/I/51A4OUiN6TL._SX377_BO1,204,203,200_.jpg",
"title": "The Magic Of Reality",
"detail": "https://www.amazon.com/Magic-Reality-Know-Whats-Really/dp/1451675046",
"description": "Richard Dawkins, bestselling author and the world’s most celebrated evolutionary biologist, has spent his career elucidating the many wonders of science. Here, he takes a broader approach and uses his unrivaled explanatory powers to illuminate the ways in which the world really works.",
"language": "en"
}
]
}
答案 0 :(得分:1)
您不应在锚(a)标记中嵌入按钮。
<a data-fancybox="images" v-bind:href="book.detail">
Show More
</a>
这应该很好!
答案 1 :(得分:0)
尝试一下
<button @click="document.location.href=book.detail">
Show More
</button>