编程式跳转

<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. R3300L按reset键无法进入USB Burning模式的问题分析

    最开始并没有注意到这个问题, 因为从设备拿到手, 用USB Burning Tool刷入潜龙版的安卓4.4.2, 再到运行EmuELEC, Armbian, 再到给Kernel 5.3的Armbian ...

  2. pd.ExcelWriter(to_excel)保存结果到已存在的excel文件中

    网易云课堂该课程链接地址 https://study.163.com/course/courseMain.htm?share=2&shareId=400000000398149&cou ...

  3. odoo开发笔记 -- 新建模块扩展原模块增加菜单示例

    场景描述: 1. 扩展了新模块 2.想要

  4. django在centos生产环境的部署

    # 安装数据库和web服务器nginx # yum install –y nginx mariadb-server # 安装虚拟环境 pip install virtualenv pip instal ...

  5. 最新sublime3配C++11编译环境

    sublime text 3. version 3.2.1 build 3207 Package control: install package : C++11 (v0.0.9; github.co ...

  6. Playbooks简介

    Playbooks简介 关于Playbooks Playbook简单示例 基本组成 主机和用户 任务列表 Handlers: 配置更改时运行操作 执行Playbook Ansible-Pull Lin ...

  7. 使用Javascript从Google Places搜索api获取纬度和经度

    如何使用谷歌地图搜索框api从搜索到的位置获取经度和纬度. 我使用与谷歌演示相同的代码 – https://developers.google.com/maps/documentation/javas ...

  8. oracle 解决 exp 空表不能导出的问题

    原因:oralce_11g 中有个新特性,当表无数据时,不分配 segment,以节省空间,这也就导致了 exp 在导出表时,没有数据的表会被忽略 方法一:我们可以向表中插入数据,在删除,这样数据表就 ...

  9. phpspreadsheet 中文文档(四) 创建电子表格+档案格式

    2019年10月11日14:01:48 该Spreadsheet班 该Spreadsheet班是PhpSpreadsheet的核心.它包含对所包含工作表,文档安全性设置和文档元数据的引用. 为了简化P ...

  10. JS系列:函数function

    ### 函数 function > 在js中函数就是一个方法(一个功能体)基于这个函数,一般是为了实现某个功能. ``` var total =10; total+=10; total=tota ...