废话不多说,直接上代码
1:在项目根目录page.json配置文件,当前的页面上配置上拉触底的距离
{
"path": "goods_list/goods_list",
"style": {
"onReachBottomDistance": 150
}
},
2:data中自定义数据
data() {
return {
//请求参数对象
queryObj: {
// 查询关键词
query: '',
// 商品分类Id
cid: '',
// 页码值
pagenum: 1,
// 每页显示多少条数据
pagesize: 10,
},
//商品列表数据
goodsList: [],
//总数量,用来实现分页
total: 0,
//节流阀
isLoading: false
};
},
3:onLoad初始化数据
onLoad(options) {
console.log(options)
this.queryObj.query = options.query || ''
this.queryObj.cid = options.cid || ''
this.getGoodsList()
},
4:methods放请求方法
methods: {
async getGoodsList() {
//开启节流阀
this.isLoading = true
const { data: