接口
http://leju.bufan.cloud/lejuClient/brand/findBrandsByPage/{start}/{limit}
封装的接口
import request from "@/api/index.js"
// 1.精选文章接口
function findArticleByPage(start, limit) {
return request({
url: `/lejuClient/product/findProductList/${start}/${limit}`,
})
}
export {
findArticleByPage,
}
封装接口之后出现的报错
页面调用
<template>
<view class="pages">
<view class="title">
<view class="e_title" v-for="(item,index) in list1" :key="index" @click.stop="e_click(index)">
<view :class="num === index ? 'title_fw_big' : 'title_color'">{{item}}</view>
</view>
</view>
<view class="content" v-if="num == 0">内容1</view>
<view class="content" v-if="num == 1">内容2</view>
</view>
</template>
<script>
import {
findArticleByPage
} from "@/api/find/index.js"
export default {
data() {
return {
list1: ['精选文章', '品牌列表'],
num: 0,
start: 1,
limit: 10,
};
},
onLoad(options) {
findArticleByPage(this.start, this.limit)
.then(res => {
console.log("精选文章", res);
})
},
methods: {
e_click(index) {
this.num = index;
},
}
};
</script>
<style lang="scss" scoped>
@import 'find.scss'
</style>
<style scoped>
// .pages {
// width: 100%;
// height: 100vh;
// background-color: #F0F0F0;
// }
.title {
display: flex;
justify-content: center;
align-items: center;
height: 80rpx;
background-color: #354e44;
position: fixed;
left: 0;
top: 0;
width: 100%;
box-sizing: border-box;
}
.e_title {
display: flex;
align-items: center;
flex-direction: column;
padding: 15rpx;
}
.title_color {
font-size: 30rpx;
color: #fff;
}
.title_fw_big {
font-size: 30rpx;
color: #fff;
border-bottom: 1rpx solid #fff;
}
.content {
margin-top: 80rpx;
width: 100%;
// height: calc(100vh - 80rpx);
}
</style>
大家给看看我封装接口部分有问题吗?调用接口之后控制台出现报错