element/examples/docs/zh-CN/installation.md

54 lines
1.5 KiB
Markdown
Raw Normal View History

2016-10-28 03:52:43 +00:00
## 安装
### npm 安装
2016-10-28 07:31:19 +00:00
推荐使用 npm 的方式安装,它能更好地和 [webpack](https://webpack.js.org/) 打包工具配合使用。
2016-10-28 03:52:43 +00:00
```shell
2016-12-18 10:43:14 +00:00
npm i element-ui -S
2016-10-28 03:52:43 +00:00
```
### CDN
目前可以通过 [unpkg.com/element-ui](https://unpkg.com/element-ui/) 获取到最新版本的资源,在页面上引入 js 和 css 文件即可开始使用。
2016-10-28 03:52:43 +00:00
```html
<!-- 引入样式 -->
2016-11-13 03:58:45 +00:00
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-default/index.css">
2016-10-28 03:52:43 +00:00
<!-- 引入组件库 -->
2016-11-13 03:58:45 +00:00
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
2016-10-28 03:52:43 +00:00
```
### Hello world
2016-10-28 07:31:19 +00:00
通过 CDN 的方式我们可以很容易地使用 Element 写出一个 Hello world 页面。[在线演示](http://codepen.io/QingWei-Li/pen/vXwJrY)
2016-10-28 03:52:43 +00:00
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- 引入样式 -->
2016-11-13 03:58:45 +00:00
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-default/index.css">
2016-10-28 03:52:43 +00:00
</head>
<body>
<div id="app">
2016-11-20 14:39:33 +00:00
<el-button @click="visible = true">按钮</el-button>
2016-10-28 03:52:43 +00:00
<el-dialog v-model="visible" title="Hello world">
<p>欢迎使用 Element</p>
</el-dialog>
</div>
</body>
<!-- 先引入 Vue -->
2016-11-13 03:58:45 +00:00
<script src="https://unpkg.com/vue/dist/vue.js"></script>
2016-10-28 03:52:43 +00:00
<!-- 引入组件库 -->
2016-11-13 03:58:45 +00:00
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
2016-10-28 03:52:43 +00:00
<script>
new Vue({
el: '#app',
data: function() {
return { visible: false }
}
})
</script>
</html>
```
2016-12-18 10:43:14 +00:00
如果是通过 npm 安装,并希望配合 webpack 使用,请阅读下一节:快速上手。