我调用的是豆瓣v2电影接口,做的是电影详情页。点击某个电影进入详情页发起请求。
html(页面图片都正常显示出来了,但是控制台会报错)
<div class="head-img"> <img :src="movieDetail.images.medium"/> </div>
js
data () { return { movieDetail: {} } }, created () { this.$http.jsonp('https://api.douban.com/v2/movie/subject/'+this.$route.params.id).then( (res) => { this.movieDetail = res.data }).catch(error => { console.log( error) }) }
但是如果js部分我这样写,就不会报错,为什么?
data () { return { movieDetail: {}, movieSrc:{}, movieAka:[], movieRating:{} } }, created () { this.$http.jsonp('https://api.douban.com/v2/movie/subject/'+this.$route.params.id).then( (res) => { this.movieDetail = res.data this.movieSrc = res.data.images this.movieAka = res.data.aka this.movieRating = res.data.rating this.$nextTick(() => { this._initPics() }) }).catch(error => { console.log( error) }) }
woshiajuana
相关分类