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

3.8 KiB

Getting Started

Ant Design Vue is dedicated to providing a good development experience for programmers. Make sure that you had installed Node.js(> v6.5) correctly.

Before delving into Ant Design Vue, a good knowledge base of Vue and JavaScript ES2015 is needed.

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.

  • Vue Antd Template

Import vue-antd-ui

1. Installation

vue-cli

$ npm install vue-cli -g

2. Create a New Project

A new project can be created using CLI tools.

$ vue init webpack antd-demo

3. Use antd's Components

$ npm i --save vue-antd-ui

Fully import

import Vue from 'vue'
import Antd from 'vue-antd-ui'
import App from './App'
import 'vue-antd-ui/dist/antd.css'
Vue.config.productionTip = false

Vue.use(Antd)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: { App },
  template: '<App/>'
})

The above imports Antd entirely. Note that CSS file needs to be imported separately.

Only import the components you need

import Vue from 'vue'
import { Button, message } from 'vue-antd-ui'
import App from './App'

Vue.config.productionTip = false

Vue.component(Button.name, Button)
Vue.prototype.$message = message

/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: { App },
  template: '<App/>'
})

All the components in antd are listed in the sidebar.

4. Component list

Component list

Compatibility

Ant Design Vue supports all the modern browsers and IE9+.

You need to provide es5-shim and es6-shim and other polyfills for IE browsers.

If you are using babel, we strongly recommend using babel-polyfill and babel-plugin-transform-runtime instead of those two shims.

Please avoid using both the babel and shim methods at the same time.

Import on Demand

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.

You are using a whole package of antd, please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.

However, we can import individual components on demand:

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

We strongly recommend using babel-plugin-import, which can convert the following code to the 'antd/lib/xxx' way:

import { Button } from 'vue-antd-ui';

And this plugin can load styles too, read usage for more details.

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.

Customization

Tips

  • You can use any npm modules.
  • Although Vue's official recommended template to write components, JSX is a better choice for complex components.