【发布时间】:2018-10-08 23:26:00
【问题描述】:
我无法在此代码中创建导航链接。这不是我的代码,但我需要制作工作网站。我不知道如何将变量(页面名称,vue-file)从脚本传递到 html-tag 。请帮忙!提前谢谢!
这是网站的主页,在这个页面上我需要点击文本“阅读更多...”并转到另一个页面。
我试过了:
<nuxt-link :to='card.link' v-for="card in cards" :key="card.image">Read more...</nuxt-link>
改为标记a,但出现错误...
-<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>
【问题讨论】: