老师看看这个

老师看看这个

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

detail.vue

<template>

<div>

<detail-banner :sighName="sighName" :bannerImgs="bannerImgs" :gallaryImgs="gallaryImgs"></detail-banner>

<detail-header></detail-header>

<div class="content">

<detail-list :list="list"></detail-list>

</div>

<div class="scroll"></div>


</div>

</template>

<script src="">

import DetailBanner from "./components/Banner"

import DetailHeader from "./components/Header"

import DetailList from "./components/List"

import axios from "axios"



export default{

name: "Detail",

components:{

DetailBanner:DetailBanner,

DetailHeader:DetailHeader,

DetailList:DetailList,

},

data(){

return{

sighName:"",

bannerImgs:"",

gallaryImgs:[],

list:[]


}

},

methods: {

getDetailInfo(){

axios.get("/api/detail.json",{

params:{

id:this.$route.params.id

}

}).then(this.handleGetDataSucc);

},

handleGetDataSucc(res){

res=res.data

if(res.ret && res.data){

const data=res.data

this.sighName=data.sighName

this.bannerImgs=data.bannerImg

this.gallaryImgs=data.gallaryImgs

this.list=data.categoryList

}

}

},

mounted() {

this.getDetailInfo()

},

}

</script>

<style lang="stylus" scoped>

.scroll

height: 50rem;

</style>

banner.vue

<template>

<div>

<div class="banner" @click="handleBannerClick">

<img :src="bannerImgs" alt="" class="banner-img">

<div class="banner-info">

<div class="banner-tittle">{{this.sighName}}</div>

<div class="banner-number">

<span class="iconfont  banner-icon" >&#xeaf2;</span>

{{this.bannerImgs.length}}

</div>

</div>

</div>

<fade-animation>

<common-gallary :imgs="gallaryImgs" v-show="showGallary" @colose="handleGAllaryClose" ></common-gallary>

</fade-animation>

</div>

</template>

<script src="">

// 使用公用组件

import CommonGallary from "common/gallary/Gallary"

import FadeAnimation from "common/fade/FadeAnimation"

export default{

name: "DetailBanner",

props:{

sighName:String,

bannerImgs:String,

gallaryImgs:Array

},

data() {

return {

showGallary:false,

}

},

components:{

CommonGallary:CommonGallary,

FadeAnimation:FadeAnimation

},

methods: {

handleBannerClick(){

this.showGallary=true

},

handleGAllaryClose(){

this.showGallary=false

}

},

}

</script>

<style lang="stylus" scoped>

.banner

position: relative;

overflow: hidden

height: 0

padding-bottom:55%

.banner-img

width:100%

.banner-info

background-image:linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,0.8))

display: flex

position:absolute

left:0

right:0

bottom:0

line-height:0.6rem

color:white

.banner-tittle

font-size0.32rem

flex:1

padding: 0 0.2rem;

.banner-number

margin-top:0.14rem

padding:0 0.4rem

line-height:0.4rem

height:0.4rem

border-radius:0.2rem

background:rgba(0,0,0,0.8)

font-size:0.24rem

.banner-icon

font-size:0.24rem


</style>


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

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

1回答
好帮手慕言 2020-09-26 10:23:04

同学你好,从报错来看,是因为bannerImgs校验不对,希望得到的是个字符串,但实际得到的是一个数组。

但是老师这边测试同学粘贴的这部分代码,没有出现报错,建议同学清除浏览器缓存再测试下,祝学习愉快~

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

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

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

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

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