跳转详情页面具体代码

写这个页面需要安装两个

1.安装axios命令

Cnpm install axios --save

2.安装vant

Cnpm install vant --save

在index.Js里面配置要跳转页面的路由

在main.js里面用vue引入刚安装上的两个插件

这个是home.vue里的内容

 <template>

  <div>

//下面那个正在加载时给它个判断

    <div v-if="isShow">正在加载......</div>

 

    <div class="div1"> 

    <div v-for="(item,index) in goods" :key="index"

    @click="gotoDetails(item.id)">

      <img :src="item.mainPic" width="150px" />

      <p>{{item.title}}</p>

      <p>

        <span style="color:red">{{item.actualPrice}}</span>

        <s style="font-size:12px">{{item.originalPrice}}</s>

      </p>

      <p>销售:{{item.monthSales}}</p>

    </div>

    <div v-for="(item,index) in goods" :key="index"

    @click="gotoDetails(item.id)">

      <img :src="item.mainPic" width="150px" />

      <p>{{item.title}}</p>

      <p>

        <span style="color:red">{{item.actualPrice}}</span>

        <s style="font-size:12px">{{item.originalPrice}}</s>

      </p>

      <p>销售:{{item.monthSales}}</p>

    </div>

</div>

  </div>

</template>

 

 <script>

export default {

  data() {

    return {

      goods: [],

      isShow: true

    };

  },

  mounted() {

this.$axios

//下面那个是在官网中引入的Apl接口

      .get(" http://api.kudesoft.cn/tdk/goods", {

        params: {

          pageId: 2,

          cids: 6

        }

      })

      .then(res => {

        let goods = res.data.data.data.list;

        this.goods = goods;

        this.isShow = false;

      })

      .catch(err => {

        console.log(err);

      });

  },

  methods: {

    gotoDetails(id) {

      this.$router.push({

        path: "/details",

        query: {

          id

        }

      });

    }

  }

};

</script>

 

 <style>

 .div1{

   width: 100%;

   display: flex;

   justify-content: space-between;

 }

</style>

这个是在跳转页面是要创建的跳转到的页面 details.vue

<template>

  <div>

    <button @click="back">返回</button>

    <van-swipe :autoplay="3000" indicator-color="white" style="width:200px">

      <van-swipe-item v-for="(img,index) in goodItem.imgs" :key="index">

        <img :src="img" alt width="200px" />

      </van-swipe-item>

    </van-swipe>

    <div>{{goodItem.title}}</div>

    <div>

      <a :href="goodItem.couponLink">领劵</a>

    </div>

    <h1>商品详情:</h1>

    <div>

      <img v-for="(url,index) in goodItem.detailPics" :key="index" :src="url" width="600px" />

    </div>

  </div>

</template>

 

<script>

export default {

  data() {

    return {

      goodItem: {}

    };

  },

  mounted() {

    let id = this.$route.query.id;

    this.$axios

      .get("http://api.kudesoft.cn/tdk/details", {

        params: {

          id

        }

      })

      .then(res => {

        this.goodItem = res.data.data.data;

        this.goodItem.imgs = this.goodItem.imgs.split(",");

        this.goodItem.detailPics = this.goodItem.detailPics.split(",");

      })

      .catch(err => {

        console.log(err);

      });

  },

  methods: {

    back() {

      window.history.back();

    }

  }

};

</script>

<style>

</style>

vue中跳转页面逻辑的更多相关文章

  1. 修改vue中的挂载页面(index.html)的路径

    修改vue中的挂载页面(index.html)的路径 2019年03月30日 12:07:12 VegasLemon 阅读数 501    版权声明:本文为博主原创文章,未经博主允许不得转载. htt ...

  2. vue中如何刷新页面

    vue中刷新页面的方法 1. 不能使用 this.$router.go(0) 或者 window.reload() 不起作用还特别恶心 这个才是有效果的刷新页面,只要照图敲,就能有效果 我们在 app ...

  3. 简述在Js或Vue中监听页面的刷新、关闭操作

    1.背景 大家是否经常遇到在关闭网页的时候,会看到一个确定是否离开当前页面的提示框?想一些在线测试系统.信息录入系统等就经常会有这一些提示,避免用户有意或者无意中关掉了页面,导致数据丢失.而最近在做项 ...

  4. vue中监听页面滚动和监听某元素滚动

    ①监听页面滚动 在生命周期mounted中进行监听滚动: mounted () { window.addEventListener('scroll', this.scrollToTop) }, 在方法 ...

  5. vue 项目 跳转 页面 不刷新 问题

    vue项目中需要导出下载客户数据,因为数据太多,响应太慢.后台直接上传给七牛  然后返回一个下载链接  前端通过跳转链接 来下载 riskManagementApi.friendExprotAll(t ...

  6. laravel中的登录页面逻辑

    <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades ...

  7. 在taro中跳转页面的时候执行两遍componentDidMount周期的原因和解决方法

    在做taro跳转的时候,发现在跳转后的页面会走两遍componentDidMount周期,查看了github上的issues,发现是跳转路由带参为中文引起的,只要把中文参数进行urlencode解决 ...

  8. vue中如果在页面中v-model的是字典,那么在定义字典的时候,需要明确定义键值为''或者[],否则给字典的键值赋值后页面不显示

    如题 在template模板中 {{}} {{form_temp.blOwnerMemberList}} #是字典的形式哦 {{}} 在return的属性中 form_temp: { blOwnerM ...

  9. vue 中监听页面滚动

    监听页面滚动 在methods中定义一个方法 handleScroll() { //获取滚动时的高度 let scrollTop = window.pageYOffset || document.do ...

随机推荐

  1. Combine 框架,从0到1 —— 4.在 Combine 中使用 KVO

      本文首发于 Ficow Shen's Blog,原文地址: Combine 框架,从0到1 -- 4.在 Combine 中使用 KVO.   内容概览 前言 用 KVO 监控改动 将 KVO 代 ...

  2. Linux常用命令详解(2)

    aliasunaliasunamesuhostnamehistorywhichwcwwhowhoamipingkillseqdudffreedate 命令详解 1. alias 设置.’查看别名 实例 ...

  3. Cobalt Strike后渗透安装和初步使用

    Cobalt Strike安装 系统要求 Cobalt Strike要求Java 1.8,Oracle Java ,或OpenJDK . 如果你的系统上装有防病毒产品,请确保在安装 Cobalt St ...

  4. netty字符串流分包

    @Override protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf in, List<Obj ...

  5. vue-router-next 通过hash模式访问页面不生效,直接刷新页面一直停留在根路由界面的解决办法

    vue3中,配合的vueRouter版本更改为vue-router-next通过 npm i vue-router@next 的方式进行引入添加,随后创建 router.js,在main.js里面引入 ...

  6. 关于python中break与continue的区别

    在python中break和continue都有跳出循环体的作用,但是他们还是有一些区别的,具体区别如下: break:是直接跳出循环,跳出自己所处的整个循环体 continue:只是跳出本次循环,而 ...

  7. 获取NX装配结构信息

    最近在做一个项目,需要获取NX装配结构信息,这里把代码分享给大家,希望对各位有帮助,注意以下几点: 1)代码获取了PART的属性.表达式等,因此一些细节可能需要您根据实际情况修改. 2)读写XML用的 ...

  8. python中浅拷贝和深拷贝的区别

    浅拷贝 可变类型浅拷贝copy函数就是浅拷贝,只对可变类型的第一层对象进行拷贝,对拷贝的对象开辟新的内存空间进行存储,不会拷贝对象内部的子对象可变类型:a = [1, 2, 3] b = [11, 2 ...

  9. C++ 双冒号开头的语法是什么

    z转载:https://blog.csdn.net/LHHopencv/article/details/78353380 命名空间限定.std::string 表示std命名空间下的 string类. ...

  10. 利用rtklib处理GPS以及北斗数据详解

    利用rtklib开源代码处理GPS以及北斗数据详解 在GNSS领域最基础的工作是这些GNSS系统的定位工作,对于绝大多数研究者,自己着手完成这些工作是一个"鸡肋":完全独立设计的话 ...