编程式跳转

<template>
<ul class = "prolist">
<!-- //产品 -->
<!-- :to = "/detail/item.id" -->
<!-- 声明式跳转 :to = "{ name: 'detail',params: { id: item.id } }" -->
<!-- <router-link :to = "{ name: 'detail',params: { id: item.id } }" tag = "li" class = "proitem" v-for="(item,index) of iss" :key='index'>
<div class = "itemimg">
<img :src="item.images.small" :alt="item.alt">
</div>
<div class = "iteminfo">
<h3>{{ item.title }}</h3>
<div class = "directors">
<span v-for="(itm,idx) of item.directors" :key="idx">
{{ itm.name }}/
</span>
</div>
<Rating :rating='(item.rating.average / 2).toFixed(1)' />
</div>
</router-link> --> <!-- 编程式跳转 -->
<!-- @click="godetail(item.id) -->
<li class = "proitem" v-for="(item,index) of iss" @click="goDetail(item.id)" :key='index'>
<div class = "itemimg">
<img :src="item.images.small" :alt="item.alt">
</div>
<div class = "iteminfo">
<h3>{{ item.title }}</h3>
<div class = "directors">
导演:<span v-for="(itm,idx) of item.directors" :key="idx">
{{ itm.name }}/
</span>
</div>
<div class = "casts">
演员:<span v-for="(itm,idx) of item.casts" :key="idx">
{{ itm.name }}/
</span>
</div>
<Rating :rating="(item.rating.average / 2).toFixed(1)"/>
</div>
</li>
</ul>
</template>
<script>
import Rating from '@/components/common/Rating' export default {
methods: {
goDetail (id) {
// console.log(this.$router)
// this.$router.push('/detail/' + id) //id由函数获得
// this.$router.push({ name: 'detail', params: { id: id } }) // 另一种方法
this.$router.push({ path: '/detail/' + id }) // 另一种方法
}
},
props: ['iss'],
components: {
Rating
}
}
</script>

router.js:

{
// path: '/detail',
path: '/detail/:id', // 详情需要配一个id,获取遍历
name: 'detail',
component: () => import('./views/detail/index.vue')
},

Vue编程式跳转的更多相关文章

  1. React-router的使用:标签跳转和编程式跳转

    目录: 1.demo:NavLink 标签跳转 2.标签渲染路由组件时,获取url参数 3.编程式跳转 参考文档 1)https://reacttraining.com/react-router/we ...

  2. vue编程式导航

    vue项目中使用到了组件间传值,通过路由跳转实现从产品页进入产品详情页查看功能. 使用了this.$router.push(编程式导航) product页面中:因为只需要遮住产品列表页来显示产品详情页 ...

  3. vue编程式路由实现新窗口打开

    一. 标签实现新窗口打开: 官方文档中说 v-link 指令被 组件指令替代,且 不支持 target=”_blank” 属性,如果需要打开一个新窗口必须要用标签,但事实上vue2版本的 是支持 ta ...

  4. vue编程式导航,命名路由

    //使用 window.location.href 的形式,叫做 编程式导航 绑定事件的形式 <template> <div class="goods-item" ...

  5. Vue编程式路由跳转传递参数

    Vue 有时在路由跳转时需要用到一些原页面里的数据,用以下方法: 1.在跳转页的方法里写下query参数 TableChange(scope){ this.$router.push({ path:'d ...

  6. Vue 编程式导航(通过js跳转页面)以及路由hash模式和history模式

    第一种方法: this.$router.push({path:'shopcontent?aid=3'}   第二种方法   this.$router.push({name:'news'}} 通过在ma ...

  7. Vue 编程式导航,路由history模式

    import Vue from 'vue' import App from './App.vue' import Home from './components/Home.vue' import Ne ...

  8. vue-router编程式跳转

    除了使用 <router-link> 创建 a 标签来定义导航链接,我们还可以借助 router 的实例方法,通过编写代码来实现. [语法] .

  9. Vue 编程式的导航

    1.应用场景 在同一路由的情况下,不同的参数之间进行切换 注意:别忘记初始化路由页面 2.用法 a.定义方法 b.实现方法 c.初始化路由页面 3.案例 <template> <di ...

随机推荐

  1. Shared variable in python's multiprocessing

    Shared variable in python's multiprocessing https://www.programcreek.com/python/example/58176/multip ...

  2. Vue日常开发问题

    1.sh: webpack-dev-server: command not found 我的公众号:

  3. 异常值检测方法(Z-score,DBSCAN,孤立森林)

     机器学习_深度学习_入门经典(博主永久免费教学视频系列) https://study.163.com/course/courseMain.htm?courseId=1006390023&sh ...

  4. jenkins服务器使用python脚本rabbitmqadmin和shell对目标服务器进行管理

    jenkins服务器使用python脚本rabbitmqadmin和shell对目标服务器进行管理 准备工作: .jenkins服务器,安装rabbitmqadmi命令 rabbitmqadmin管理 ...

  5. FineReport简单部署

    一.部署方式 1.官网发布包部署 2.自定义tomcat部署 二.发布包部署 1.下载一个发布包:https://www.finereport.com/product/download 解压后打开bi ...

  6. 经常开车的朋友必备 它是你的GPS

    经常开车的朋友肯定知道,每天都要查下当天的限行尾号,还有哪条路拥堵.还有,最不想发生的事儿就是车子快没油的时候,附近查不到加油站. 现在用这款小程序,可以轻松解决上述这些头痛的事情.扫描下面二维码,进 ...

  7. C++11 并发编程库

    C++11 并发编程 C++11 新标准中引入了几个头文件来支持多线程编程,他们分别是: <atomic>:该头文主要声明了两个类, std::atomic 和 std::atomic_f ...

  8. ODAC Developer Downloads - Oracle Universal Installer

    https://www.baidu.com/link?url=BL2vRNMWap6AFJcmsFCEKi3KxZ2SgmtVJoihVKhF-SPgzvJHNkbk_j7nz1HdtAAWZ22NM ...

  9. [ARM-Linux开发]Linux open函数

    Linux open函数 open 函数用于打开和创建文件.以下是 open 函数的简单描述 #include <fcntl.h> int open(const char *pathnam ...

  10. oracle登录信息对应

    登录数据库填写的是,配置文件中自己定义的值 2. 查询非纯数字值的字段内容 select trim(translate(RTRIM(LTRIM(ITEM_NUMBER)), '#0123456789' ...