npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-element-crud

v3.2.0-alpha

Published

A CRUD component for vue projects to create, retrieve, update and destroy models.

Downloads

116

Readme

vue-element-crud

A wrapped vue CRUD component based on the famous vue UI componets -- element-ui.

一款基于 element-ui 组件的增删改查组件。

Here is a simple demo.

您可以阅读项目中的示例 examples 和源码文件 Crud.vue 来帮助您理解组件的具体用法。

Local development

You can download or clone this repository as long as you like it. Then you can run npm scripts

$ npm run build:watch

Usage

You can use vue-element-crud as a vue plugin or as a vue component.

If you'd like to treat it as a componet. You can import CRUD as components.

As component

import { CRUD } from 'vue-element-crud'
// or you can import from 'vue-element-crud/lib/crud.common' for en users

export default {
  components: { crud: CRUD },
}

Otherwise, you can treat it as a plugin.

As Plugin

Step-1, init project

You may need to init a vue project or take a existing one to continue as vue-loader or babel-loader or css-loader is required for element-ui.

$ vue init webpack <project-name>

Step-2, install

This component is dependent on element-ui, and element-ui will automatically installed when you install vue-element-crud, so you don't have to install element-ui in addition.

$ npm install -S vue-element-crud

Step-3, vue use

Add these lines below to your main.js

import 'element-ui/lib/theme-default/index.css'
import ElementUI from 'element-ui'
import CRUD from 'vue-element-crud'

Vue.use(ElementUI)
Vue.use(CRUD)

Step-4, refer to examples

You can read the docs or examples to find out how to implement props and methods of this vue-element-crud.

API

| props | type | required | default | description | | :-----------------: | :------: | :------: | :-------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------: | | data | Array | true | --- | Table data array | | form | Object | true | --- | Form object to store form item varaibles | | fields | Object | true | --- | Object that describes form items structure. eg. { name: { label: 'name', length: 20, type: String, options: [{ label: 'Mike', value: 'Mike' }] } | | rules | Object | false | --- | Object that describes form items rules. eg. { name: [{ required: true, message: 'name is required.' }] } | | size | String | false | 'large' | Size the dialog. 'full' or 'large' or small or omitted. | | labelWidth | String | false | '100px' | Label width of form and table. | | inline | Boolean | false | false | Determine whether form items live inline or not. | | table | Object | false | --- | If table structure is not according to the form structure, you can specify it. eg. { name: 'name' } | | actions | Array | false | ['create', 'destroy', 'update'] | The crud actions. | | loading | Boolean | false | false | CRUD is in XHR state. Submit button was disabled if true. | | highlightCurrentRow | Boolean | false | false | Highlight table current row or not. | | rowStyle | Function | false | --- | Table row style function. Function(row, index) |

| events | description | | :----------: | :--------------------------------------------------------------------------------------------------------------------------------------------------: | | open | dialog open event. set editing to true to show the dialog. | | close | dialog close event. set editing to false to close the dialog. | | create | form create event. You need to assign form model to the form. | | update | form update event. (row, index) passed to the handler. You need to assign row to the form. | | destroy | table row destory event. (row, index) passed to the handler. | | submit | form submit event. (status, closeDialog) passed to the handler. 0 stands for creating, and 1 stands for updating. closeDialog is a function. | | expand | table expand event. (row, expanded) passed to the handler. See element-ui table events. | | row-click | table row click event. (row, event, column) passed to the handler. See element-ui table events. | | row-dblclick | table row dblclick event. (row, event) passed to the handler. See element-ui table events. |

| slots | description | | :-----: | :-----------------------------------------------: | | index | Table row index slot. See element-ui table slots. | | expand | Table expand slot. See element-ui table slots. | | prepend | Table prepend slot. | | default | Table append slot. | | addon | Form addon slot. |

Your template may look like this.

<crud :data="data" :form="form" :rules="rules" :fields="fields" inline index
    :editing="editing" @open="handleOpen" @close="handleClose"
    @create="handleCreate" @update="handleUpdate" @destroy="handleDestroy" @submit="handleSubmit"/>

Here is a simple mixin that may help you to bootstrap it. Just import Simple.

import { Simple } from 'vue-element-crud'

export {
  mixins: [Simple]
}

Contribute

If you have some ideas about this component, please don't hesitate to let us konw. You can make a new issue to make it better.