老衲as用飘柔 2022-10-10 11:39 采纳率: 100%
浏览 178
已结题

uni-app接口封装调用失败

接口

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,
}

封装接口之后出现的报错

img

页面调用

<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>

大家给看看我封装接口部分有问题吗?调用接口之后控制台出现报错

  • 写回答

3条回答 默认 最新

  • 飞鱼爱吃米 2022-10-10 13:07
    关注

    你给大伙看看你封装的request

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 10月19日
  • 已采纳回答 10月11日
  • 创建了问题 10月10日

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿