• mock数据的使用方法


    安装  npm install mockjs

    1.创建mock.js

    const Mock = require('mockjs');
    // mock一组数据
    const deptList = ['内科一病区', '骨科一病区', '内科二病区', '骨科二病区', '内科二病区', '骨科二病区',]
    const deptDrugDate = function () {
        let articles = [];
        for (let i = 0; i < 4; i++) {
            let newArticleObje = {
                execDeptName: deptList[i],
                itemName: drugNameList[i],
                hospitalName: "基层云医疗",
                itemSpec: drugSpecList[i],
                UNIT: unitList[i],
                PRICE: priceList[i],
                AMOUNT: amountList[i],
                COSTS: priceList[i] * amountList[i],
            }
            articles.push(newArticleObje);
        }
        return {
            Details: articles,
            Master: {
                beginDate: "2021-01-05",
                date: "2021-01-05 15:42",
                endDate: "2021-01-05",
                operName: "鄢宁",
                hospitalName: "基层云医疗",
                costs: 0,
            }
        }
    }
    
    // 需要几个接口就定义几个function,
    //Mock.mock(url(接口地址),method(接口方式),上面定义的数据);
    Mock.mock('/deptDrug', 'post', deptDrugDate);
    

    2.在main.js里面进行全局引用注册

    require('./mock/mock.js');
    

    3.在.vue文件正常使用即可

       axios.post('/deptDrug').then((res) => {
            console.log(res)
          })
    

      

      

  • 相关阅读:
    HDU 1013 Digital Roots
    HDU 1290 献给杭电五十周年校庆的礼物
    几何分割问题
    HDU 1222 Wolf and Rabbit
    HDU 1997 汉诺塔VII
    HDU 1443 Joseph
    HTML的标题样式
    HDU 1568 Fibonacci
    Hope
    HDU 1071 The area
  • 原文地址:https://www.cnblogs.com/yn-cn/p/14487093.html
Copyright © 2020-2023  润新知