如何使用脚本导航 <a> 标签中的链接?

How do I navigate links in the <a> tag using a script?

我无法在此代码中创建导航链接。这不是我的代码,但我需要创建工作站点。我不知道,如何将变量(页面名称,vue-file)从脚本传递到 html-tag 。请帮忙!提前致谢!

这是站点的主页,在此页面上我需要单击文本 "Read more..." 并转到另一页。

我试过了:

<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>

查看 <nuxt-link> 组件:

https://nuxtjs.org/api/components-nuxt-link/

<template>
 <div>
  <h1>Home page</h1>
   <nuxt-link to="/about">About</nuxt-link>
</div>

我对nuxt不是很熟悉。刚找到它。可能有帮助

我完成了任务:

<a :href="card.link" class="button-go">Read more...</a>

很简单。