发表于: 2020-01-10 23:35:16

1 1228



今天完成的事情:

1.单独拆了下分页器的组件,本来想用依赖注入。不过感觉好像没有必要。就用props传值就行了


完成的事情:

1.完成搜索功能


完成的事情:

1.父组件:

<pagination :queryInfo="queryInfo" :get="getArticleList"></pagination>


data() {
   return {
     articleList: [],//回的数组
           queryInfo: {
       size: 0,//前每页显示多少条数
              total: 1,//总个数
              page: 1//页数
       }
   }
}


子组件内用props接受,并写明object属性

props: {
//总数
   queryInfo:Object

},


然后再将之前分页器的方法写进子组件


父组件内只要检测到路由变化,就执行axios的方法,并将路由的参数赋予页码和页数,传到子组件

watch: {
   // 如果路由有化,再次方法
   '$route'(to, from) {
       this.queryInfo.size = Number(this.$route.query.numPage ? this.$route.query.numPage : 10)
       this.queryInfo.page = Number(this.$route.query.currentPage ? this.$route.query.currentPage : 1)
       this.getArticleList()
   }
}



嗯。。感觉我脑子有点没完全理解好。

玄学编程





返回列表 返回列表
评论

    分享到