页面跳转以后没有显示产品组件啊,

页面跳转以后没有显示产品组件啊,

product组件:

<template>

  <div class="product">

    我的产品

  </div>

</template>


<script>

export default {

  name: 'product'

}

</script>


<style lang='scss' scoped>

.product

  overflow hidden

  width 100%

  height 100%

  background black

  position absolute

  left 0

  top 0

  z-index 20000

</style>

路由页:

import Vue from 'vue'

import Router from 'vue-router'

Vue.use(Router)


export default new Router({

  routes: [

    {

      name: 'home',

      path: '/home',

      component: () => import('pages/home'),

      children: [

        {

          name: 'home-product',

          path: 'product/:id',

          component: () => import('pages/product')

        }

      ]

    },

    {

      name: 'category',

      path: '/category',

      component: () => import('pages/category')

    },

    {

      name: 'cart',

      path: '/cart',

      component: () => import('pages/cart')

    },

    {

      name: 'personal',

      path: '/personal',

      component: () => import('pages/personel')

    },

    {

      name: 'search',

      path: '/search',

      component: () => import('pages/search')

    },

    {

      path: '*',

      redirect: '/home'

    }

  ]

})


recommend页面:

<template>

  <div class="recommend">

    <h3 class="recommend-title">热卖推荐</h3>

    <ul class="recommend-list">

      <li class="item" v-for="(item,index) of recommendList" :key=index>

        <router-link class="item-link" :to="{name:'home-product',params:{id:item.baseinfo.itemId}}">

          <p class="recommend-pic"><img class="recommend-img" :src="item.baseinfo.picUrl"></p>

          <p class="recommend-name">{{item.name.shortName}}</p>

          <p class="recommend-origPrice"><del>¥{{item.price.origPrice}}</del></p>

          <p class="recommend-info">

            <span class="recommend-price">¥<strong class="recommend-price-num">{{item.price.actPrice}}</strong></span>

            <span class="recommend-count">{{item.remind.soldCount}}件已售</span>

          </p>

        </router-link>

      </li>

    </ul>

  </div>

</template>

<script>

import {getHomeRecommend} from 'api/home'

export default {

  name: 'homeRecommend',

  data () {

    return {

      recommendList: [],

      curPage: 1,

      totalPage: 1

    }

  },

  created () {

    this.getRecommend()

  },

  methods: {

    getRecommend () {

      if (this.curPage > this.totalPage) {

        return

      }

      getHomeRecommend(this.curPage).then(data => {

        if (data) {

          this.curPage++

          this.totalPage = data.totalPage

          this.recommendList = this.recommendList.concat(data.itemList)

        }

      })

    }

  }

}

</script>

<style lang="scss" scoped>

  @import '~@/assets/stylus/mixin';

  .recommend

    {width: 100%;}

    &-title

      {position: relative;

      padding: 10px 0;

      width: 100%;

      text-align: center;

      font-size: 12px;}

      &:before,&:after

        {content: '';

        position: absolute;

        height: 1px;

        width: 40%;

        top: 50%;

        background-color: #ddd;}

      &:before

        {left: 0;}

      &:after

        {right: 0;}

    &-list

      {display:flex;

      justify-content: center;

      flex-wrap: wrap;}

      .item

        {width: 49%;

        background-color: #fff;

        box-shadow: 0 1px 1px 0 rgba(0,0,0,0.12);

        margin-bottom: 8px;

        position: relative;}

        &-link

          {display: block;}

        .recommend-pic

          {width: 100%;

          padding-bottom: 100%;

          height: 0;

          margin-bottom: 5px;}

          .recommend-img

            {width: 100%;}

        .recommend-name

          {padding: 0 10px;

          multiline-ellipsis();}

        .recommend-origPrice

          {padding: 10px 20px 10px;}

        .recommend-info

          {flex-between();

          padding: 10px;

          margin-bottom: 15px;}

          .recommend-price

            {font-size: 16px;

            color: red;}

          .recommend-count

            {font-size: 12px;}

  </style>


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
樱桃小胖子 2020-04-07 10:43:15

同学你好,使用同学的代码测试时显示了product的页面的。之所以没有显示具体的商品详情,是因为在product中没有书写相关的代码,老师点击跳转显示是因为为了保证演示效果,提前准备好了代码,并且,这部分的详细内容是课后作业哦。

http://img1.sycdn.imooc.com//climg/5e8be8a60908b5cc16740919.jpg

如果我的回答帮助了你,希望采纳,祝学习愉快!

樱桃小胖子 2020-04-06 16:39:22

同学你好,建议先检查一下是否有报错,报错信息是什么,以及检测一下如下代码是否正确,上传上来的代码,属性和属性值之间缺少冒号,属性值后面缺少分号分隔。

http://img1.sycdn.imooc.com//climg/5e8aea900956a08c03570432.jpg

祝学习愉快!

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师