V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
Marstin
V2EX  ›  分享创造

自动生成 Vue+ElementUI 增删改查代码插件

  •  
  •   Marstin ·
    Marstin · 2020-09-04 08:56:35 +08:00 · 2045 次点击
    这是一个创建于 1330 天前的主题,其中的信息可能已经有所发展或是发生改变。

    webpack 插件,目的是为了在简单的 CURD 动作中减少Ctrl+cCtrl+v

    webpack配置文件 或 Vue-Cli配置文件中配置一下下,即可生成对应目录中的代码。可配置数据 Model,增删改查四项功能搭配,请求配置与自定义等

    npm install curd-vue-element-plugin -D
    
    const CurdVueElementPlugin = require('curd-vue-element-plugin')
    
    plugins: [
      new CurdVueElementPlugin({
        baseDir: './src',
        options: [{
          name: 'project',
          service: ['list', 'add', 'update', 'del'],
          component: {
            primaryKey: 'id',
            model: [{
              name: 'name',
              text: '姓名',
              isSearch: true
            }, {
              name: 'sex',
              text: '性别'
            }, {
              name: 'telephone',
              text: '手机号码',
              isSearch: true
            }, {
              name: 'email',
              text: '邮箱'
            }, {
              name: 'address',
              text: '地址',
              isEdit: false
            }]
          }
        },
        {
        //……options
        },
        {
        //……options
        }]
      })
    ]
    

    详见 curd-vue-element-plugin

    2 条回复    2020-09-04 10:56:54 +08:00
    NikoXu
        1
    NikoXu  
       2020-09-04 10:14:41 +08:00
    能定义模版吗
    Marstin
        2
    Marstin  
    OP
       2020-09-04 10:56:54 +08:00
    @NikoXu 不能
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5507 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 06:44 · PVG 14:44 · LAX 23:44 · JFK 02:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.