I can't make navigate links in this code. It's not my code, but I need to make working site. I don't know, how to pass variable (page name, vue-file) from script to html-tag . Please, help! Thank you in advance!
This is main page of site, on this page I need click on text "Read more..." and go to another page.
I tried:
<nuxt-link :to='card.link' v-for="card in cards" :key="card.image">Read more...</nuxt-link>
instead tag a, but an error occured...
-<template>
<div>
<div class="subtitle">
<h2>Some text</h2>
<div class="text">
Some text
</div>
<div class="main-tasks">
<img class="photo" src="images/index/act59440c9c55367.jpg" alt="Univercity">
<div class="subtitle2">
<h2>Some text</h2>
</div>
<div class="tasks">
Some text
</div>
</div>
</div>
<div class="card-wrap">
<div class="card" v-for="card in cards" :key="card.image">
<h2 class="card-title">{{card.title}}</h2>
<img class="img-card" :src="'/images/index/' + card.image + '.png'" alt="npo">
<p class="card-description">{{card.description}}</p>
<br>
<a href="#" class="button-go">Read more...</a> <!-- Here I need to pass the values in the form of page names -->
</div>
</div>
</div>
</template>
<style>
.text{
max-width: 100%;
padding: 0;
text-align: left;
}
.tasks{
max-width: 100%;
margin: 0;
}
.card {
width: 100%;
margin: -1em 0 -1em;
padding: 10px 10px;
padding-right: 1.25rem;
padding-left: 1.25rem;
text-align: center;
}
.card-title {
margin: 2em 0 1em;
padding: 20px 10px;
text-align: center;
color: white;
border-radius: 3px;
background-color: rgb(85, 85, 87);
}
.img-card {
max-width: 60%;
}
.description {
margin-bottom: 1rem;
text-align: center;
opacity: .7;
color: grey;
}
.card-wrap {
display: flex;
margin-right: .5rem;
margin-bottom: 2rem;
margin-left: .5rem;
text-align: center;
text-decoration: none;
letter-spacing: .025em;
background-color: white;
}
.button-go {
font-weight: 700;
padding: .8em 1em calc(.9em + 2px);
text-decoration: none;
color: white;
border-radius: 3px;
background: rgb(101, 161, 218);
}
</style>
<script>
export default {
data () {
return {
cards: [
{
link: 'rnd',
title: 'R&D',
image: '1',
description: 'Some text'
},
{
link: 'develop',
title: 'Development',
image: '2',
description: 'Some text'
},
{
link: 'edu',
title: 'Education',
image: '3',
description: 'Some text'
}
]
}
}
}
</script>
答案 0 :(得分:1)
请参阅<nuxt-link>
组件:
https://nuxtjs.org/api/components-nuxt-link/
<template>
<div>
<h1>Home page</h1>
<nuxt-link to="/about">About</nuxt-link>
</div>
我对nuxt并不熟悉。刚发现它。可能会有所帮助
答案 1 :(得分:0)
我解决了任务:
<a :href="card.link" class="button-go">Read more...</a>
很简单。