vue.js - 路由器链接绑定(bind)到 b 卡图像

标签 vue.js single-page-application router bootstrap-vue

是否可以将 router-link 绑定(bind)到 b-card 的 image 属性,它们是
物理上不存在,我想在图像点击时切换链接

 <b-col lg="3" v-for="product in products" v-bind:key="product.id">
     <b-card 
      v-bind:title="product.title"
      v-bind:img-src="product.img"
      v-bind:img-alt="product.alt"
      img-top
      tag="article"
      style="max-width: 20rem;"
      class="mb-2">
      <b-card-text>Some quick example text to build on the card title and 
       make up the bulk of the card's content.</b-card-text>
      </b-card>
   </b-col>

有没有不手动创建“img”标签的解决方案?

最佳答案

这是我找到的最佳解决方案

<b-card no-body
      v-bind:title="product.title" 
      v-bind:img-alt="product.alt"
      img-top
      tag="article"
      style="max-width: 20rem;"
      class="mb-2"
    >
    <router-link :to="/someurl">
    <b-card-img :src="product.img"/> 
    </router-link>
    <b-card-body>
       <b-card-title>CCCCCCCCc</b-card-title>
       <b-card-text>Some quick example text to build on the card title and make up 
         the 
        bulk of the card's content.</b-card-text>
      </b-card-body>
     </b-card>
   </b-col>

关于vue.js - 路由器链接绑定(bind)到 b 卡图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56034147/

相关文章:

vue.js - Vue 计算属性不响应状态变化

javascript - 为什么 Vue 的共享状态在没有 parseInt 的情况下不会更新?

javascript - 什么是 <router-view :key ="$route.fullPath">?

oauth-2.0 - 我可以在 SPA 中使用资源所有者密码流吗?

javascript - 带有参数导航返回的 React Router 需要双击

javascript - 在 Vue 应用程序中模拟 axios 以进行前端测试

javascript - 单页应用程序 - 我应该在服务器端使用 MVC 框架吗?

javascript - 从 API Angular 获取图像

angularjs - 具有深度嵌套路由的 Angular2 路由 v3.0.0

ios - 如何让 2 个泛型使用相同的 T 类型