
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
element-ui-for-gov
Advanced tools
npm install element-ui-for-gov -S
import Vue from 'vue'
import ElementUIForGov from 'element-ui-for-gov'
Vue.use(ElementUIForGov)
// or
import {
Select,
Button
// ...
} from 'element-ui-for-gov'
Vue.component(Select.name, Select)
Vue.component(Button.name, Button)
在 main.js 中写入以下内容:
import Vue from 'vue';
import ElementUIForGov from 'element-ui-for-gov';
import 'element-ui-for-gov/lib/theme-chalk/index.css';
import App from './App.vue';
Vue.use(ElementUIForGov);
new Vue({
el: '#app',
render: h => h(App)
});
以上代码便完成了 element-ui-for-gov 的引入。需要注意的是,样式文件需要单独引入。
借助 babel-plugin-component,我们可以只引入需要的组件,以达到减小项目体积的目的。
首先,安装 babel-plugin-component:
npm install babel-plugin-component -D
然后,将 .babelrc 修改为:
{
"presets": [["es2015", { "modules": false }]],
"plugins": [
[
"component",
{
"libraryName": "element-ui-for-gov",
"styleLibraryName": "theme-chalk"
}
]
]
}
接下来,如果你只希望引入部分组件,比如 Button 和 Select,那么需要在 main.js 中写入以下内容:
import Vue from 'vue';
import { Button, Select } from 'element-ui-for-gov';
import 'element-ui-for-gov/lib/theme-chalk/button.css';
import 'element-ui-for-gov/lib/theme-chalk/select.css';
import App from './App.vue';
Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
/* 或写为
* Vue.use(Button)
* Vue.use(Select)
*/
new Vue({
el: '#app',
render: h => h(App)
});
至此,一个基于 Vue 和 Element-ui-for-gov 的开发环境已经搭建完毕,现在就可以编写代码了。各个组件的使用方法请参阅它们各自的文档。
现代浏览器和ie 10+.
project
│ ...
│
└───packages
│ │ button // 组件
│ │ input
│ │ ...
│ │
│ └───theme-chalk // 组件样式
│ │
│ └───src
│ │ button.scss
│ │ input.scss
│ │ ...
│
└───examples
│ ...
│
└───docs
│
└───zh-CN
│ button.md // 组件说明文档
│ input.md
│ ...
首先你需要 Node.js 4+,yarn 和 npm 3+。注意:我们使用 yarn 进行依赖版本的锁定,所以请不要使用 npm install 安装依赖。
npm run bootstrap
npm run dev
# open http://localhost:8085
提示:可以运行
npm run dev:play,修改examples/play/index.vue文件,调用你修改后的组件,仍然访问 http://localhost:8085,查看修改效果,更快更方便。
npm run new newComponentName 自动创建组件目录结构,包含入口文件、样式文件、文档npm run dist
更新至element 2021/11/18 Form: validate method reject error info (#21374) Select: fix keydown event when composition (#21336) Table: fix resizeObserver loop limit exceeded (#21255) Descriptions: fix label slot bug (#21462) Table: fix toggleAllSelection bug when table is empty (#21456) Button: fix disabled priority (#21375) Table: optimize performance (#21330)
FAQs
element-ui for gov
We found that element-ui-for-gov demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.