You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design-vue/docs/vue/getting-started.en-US.md

114 lines
3.5 KiB

7 years ago
# Getting Started
7 years ago
Ant Design Vue is dedicated to providing a **good development experience** for programmers. Make sure that you had installed [Node.js](https://nodejs.org/)(> v6.5) correctly.
7 years ago
7 years ago
> Before delving into Ant Design Vue, a good knowledge base of [Vue](https://cn.vuejs.org/) and [JavaScript ES2015](http://babeljs.io/docs/learn-es2015/) is needed.
7 years ago
## Playground
The following CodeSandbox demo is the simplest use case, and it's also a good habit to fork this demo to provide a re-producible demo while reporting a bug.
7 years ago
- [![Vue Antd Template](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/2wpk21kzvr)
7 years ago
7 years ago
## Import vue-antd-ui
7 years ago
### 1. Installation
7 years ago
[vue-cli](https://github.com/vuejs/vue-cli)
7 years ago
```bash
7 years ago
$ npm install vue-cli -g
7 years ago
```
### 2. Create a New Project
A new project can be created using CLI tools.
```bash
7 years ago
$ vue init webpack antd-demo
7 years ago
```
### 3. Use antd's Components
7 years ago
```bash
$ npm i --save vue-antd-ui
7 years ago
```
**Only import the components you need**
7 years ago
```jsx
import Vue from 'vue'
import { Button, message } from 'vue-antd-ui'
import App from './App'
7 years ago
7 years ago
Vue.config.productionTip = false
7 years ago
7 years ago
Vue.component(Button.name, Button)
Vue.prototype.$message = message
7 years ago
7 years ago
/* eslint-disable no-new */
new Vue({
el: '#app',
components: { App },
template: '<App/>'
})
7 years ago
```
7 years ago
> All the components in antd are listed in the sidebar.
7 years ago
7 years ago
### 4. Component list
7 years ago
7 years ago
[Component list](https://github.com/vueComponent/ant-design/blob/master/site/components.js)
7 years ago
## Compatibility
7 years ago
Ant Design Vue supports all the modern browsers and IE9+.
7 years ago
You need to provide [es5-shim](https://github.com/es-shims/es5-shim) and [es6-shim](https://github.com/paulmillr/es6-shim) and other polyfills for IE browsers.
If you are using babel, we strongly recommend using [babel-polyfill](https://babeljs.io/docs/usage/polyfill/) and [babel-plugin-transform-runtime](https://babeljs.io/docs/plugins/transform-runtime/) instead of those two shims.
> Please avoid using both the babel and shim methods at the same time.
## Import on Demand
7 years ago
If you see logs like below screenshot, you might be importing all components by writing `import { Button } from 'vue-antd-ui';`. This will affect your app's network performance.
7 years ago
```
You are using a whole package of antd, please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.
```
> ![](https://zos.alipayobjects.com/rmsportal/GHIRszVcmjccgZRakJDQ.png)
However, we can import individual components on demand:
```jsx
7 years ago
import Button from 'vue-antd-ui/lib/button';
import 'vue-antd-ui/lib/button/style'; // or vue-antd-ui/lib/button/style/css for css format file
7 years ago
```
We strongly recommend using [babel-plugin-import](https://github.com/ant-design/babel-plugin-import), which can convert the following code to the 'antd/lib/xxx' way:
```jsx
7 years ago
import { Button } from 'vue-antd-ui';
7 years ago
```
And this plugin can load styles too, read [usage](https://github.com/ant-design/babel-plugin-import#usage) for more details.
7 years ago
> FYI, babel-plugin-import's `style` option will importing some global reset styles, don't use it if you don't need those styles. You can import styles manually via `import 'vue-antd-ui/dist/antd.css'` and override the global reset styles.
7 years ago
## Customization
7 years ago
- [Customize Theme](/ant-design/docs/vue/customize-theme)
7 years ago
- [Local Iconfont](https://github.com/ant-design/antd-init/tree/master/examples/local-iconfont)
## Tips
- You can use any `npm` modules.
7 years ago
- Although Vue's official recommended template to write components, JSX is a better choice for complex components.