1.先在中配置路由
{
path: '/movieDetail/:movieId',
name: 'movieDetail',
component:movieDetail
}
2.获取详情页的id,并派发父组件事件()页面
。。。。。。。
methods:{
selectItem(item){
//();
//var item = ;
this.$emit('select',item);
}
3.在movieShow页面引用页面
//转入电影详情页
movieDetail(item){
(`${}`);
this.$({
path: `/movieDetail/${}`
})
}
效果如下:
上面获取到了 id,接下来实现详情页通过id获取数据
1)先获取传过来的id
var movieId = that.$ && that.$;
2)引用豆瓣网的API
/v2/movie/subject/:id 单个电影条目信息
const url = `api/movie/subject/${movieId}`;
that.$(url)
.then((res)=>{
();
})
效果如下
3)在页面中引用
。。。。。。
在js中将movieDetail进行赋值 movieDetail =
data(){
return {
movieDetail:{}
}
},
created(){
this._getDateil();
},
components:{
scroll
},
methods:{
_getDateil(){
var that = this;
var movieId = that.$ && that.$;
(movieId);
//(movieId);
const url = `api/movie/subject/${movieId}`;
that.$(url)
.then((res)=>{
();
movieDetail = ;
})
},