个人分享

个人分享

1. 数据mock

我们正常的开发业务中,往往开放方式是 界面与功能逻辑同时进行。前端对数据依赖性太强。

借助rap2灵活的在线数据伪造 解决开发阶段前端数据mock

针对状态部分的验证 可直接在rap2线上改动刷新页面就好 避免本地server改动后频繁npm run…

rap2

{
  "data|2-14": [
    {
      "code": "@natural",
      "name": "@cword(3)",
      "measureUnit": "@pick([\"根\",\"颗\"])",
      "budgetUnitPrice": "@float(60, 100, 4, 9)",
      "budgetQuantity": "@integer(20, 1000)",
      "budgetAmount": "@float(60, 100, 4, 9)",
      "budgetCumulativeQuantity": "@integer(20, 1000)",
      "budgetCumulativeAmount": "@float(60, 100, 4, 9)",
      "actualUnitPrice": "@float(60, 100, 4, 9)",
      "actualQuantity": "@integer(20, 1000)",
      "actualAmount": "@float(60, 100, 4, 9)",
      "actualCumulativeUnitPrice": "@float(60, 100, 4, 9)",
      "actualCumulativeQuantity": "@integer(20, 1000)",
      "actualCumulativeAmount": "@float(60, 100, 4, 9)",
      "quantityDifferQuantity": "@integer(20, 1000)",
      "quantityDifferAmount": "@float(60, 100, 4, 9)",
      "priceDifferPrice": "@float(60, 100, 4, 9)",
      "priceDifferAmount": "@float(60, 100, 4, 9)",
      "differAmount": "@float(60, 100, 4, 9)",
      "cumulativeQuantityDifferQuantity": "@integer(20, 1000)",
      "cumulativeQuantityDifferAmount": "@float(60, 100, 4, 9)",
      "cumulativePriceDifferPrice": "@float(60, 100, 4, 9)",
      "cumulativePriceDifferAmount": "@float(60, 100, 4, 9)",
      "cumulativeDifferAmount": "@float(60, 100,43,95)"
    }
  ]
}

server 层

const client = require('@mctech/infra-cloud').getRpcClient()

const rap2 = client.bind({ url: 'http://rap2.taobao.org:38080/' })

const mockData = async (url) => await rap2.get({ path: url })

module.exports = [
  {
     
     description:'接口描述',
     url:'接口url',
     method:'请求方式',
     res:{
     async mock () {
        const result = await mockData('app/mock/258274/projects/orgId/project-labor')
        // 树形结构 可以在这里做 数据合并 id/pid
        return result
      },
      handler (params, ctx, next) {
        ...
      }
     }
  },
  ...
]

UI层
正常的api调用方式

2. 破碎的F5

为解放F5刷新 解决前端文件变动 自动刷新浏览器

  • VScode 扩展 Live Server 了解一下

  • 浏览器端插件 Live Server Web Extension 配合使用

这块建议:习惯开自动保存的小伙伴注意啦 写代码的时候浏览器刷的飞起

3. VScode支持 mussel-ui 提示

正对经常使用到的mussel组件VScode没有好的代码提示支持 我们自己整了一个 将mussel-ui以及经常使用的代码模块 整了一个本地vsix扩展

GitHub - langlangbody/mcweb-snippets: 代码提示工具

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值