|
| 1 | + |
| 2 | +## 安装 |
| 3 | + |
| 4 | +### CDN 方式使用 |
| 5 | + |
| 6 | +通过 https://unpkg.com/vue-easytable 可以看到 vue-easytable 最新版本的资源,也可以切换版本选择需要的资源,在页面上引入 js 和 css 文件即可开始使用: |
| 7 | + |
| 8 | +```css |
| 9 | +<!-- 引入样式 --> |
| 10 | +<link rel="stylesheet" href="https://unpkg.com/vue-easytable/umd/css/index.css"> |
| 11 | +<!-- 引入Vue --> |
| 12 | +<script src="https://unpkg.com/vue/dist/vue.js"></script> |
| 13 | +<!-- 引入组件库 --> |
| 14 | +<script src="https://unpkg.com/vue-easytable/umd/js/index.js"></script> |
| 15 | +``` |
| 16 | + |
| 17 | +### 示例 |
| 18 | +``` html |
| 19 | +<!DOCTYPE html> |
| 20 | +<html> |
| 21 | +<head> |
| 22 | + <meta charset="UTF-8"> |
| 23 | + <!-- 引入样式 --> |
| 24 | + <link rel="stylesheet" href="https://unpkg.com/vue-easytable/umd/css/index.css"> |
| 25 | +</head> |
| 26 | +<body> |
| 27 | +<div id="app"> |
| 28 | + <v-table |
| 29 | + :width="1000" |
| 30 | + :columns="columns" |
| 31 | + :table-data="tableData" |
| 32 | + :show-vertical-border="false" |
| 33 | + ></v-table> |
| 34 | +</div> |
| 35 | +</body> |
| 36 | +<!-- 先引入 Vue --> |
| 37 | +<script src="https://unpkg.com/vue/dist/vue.js"></script> |
| 38 | +<!-- 引入组件库 --> |
| 39 | +<script src="https://unpkg.com/vue-easytable/umd/js/index.js"></script> |
| 40 | +<script> |
| 41 | + new Vue({ |
| 42 | + el: '#app', |
| 43 | + data: function() { |
| 44 | + return { |
| 45 | + tableData: [ |
| 46 | + {"name":"赵伟","tel":"156*****1987","hobby":"钢琴、书法、唱歌","address":"上海市黄浦区金陵东路569号17楼"}, |
| 47 | + {"name":"李伟","tel":"182*****1538","hobby":"钢琴、书法、唱歌","address":"上海市奉贤区南桥镇立新路12号2楼"}, |
| 48 | + {"name":"孙伟","tel":"161*****0097","hobby":"钢琴、书法、唱歌","address":"上海市崇明县城桥镇八一路739号"}, |
| 49 | + {"name":"周伟","tel":"197*****1123","hobby":"钢琴、书法、唱歌","address":"上海市青浦区青浦镇章浜路24号"}, |
| 50 | + {"name":"吴伟","tel":"183*****6678","hobby":"钢琴、书法、唱歌","address":"上海市松江区乐都西路867-871号"} |
| 51 | + ], |
| 52 | + columns: [ |
| 53 | + {field: 'name', title:'姓名', width: 100, titleAlign: 'center',columnAlign:'center'}, |
| 54 | + {field: 'tel', title: '手机号码', width: 260, titleAlign: 'center',columnAlign:'center'}, |
| 55 | + {field: 'hobby', title: '爱好', width: 330, titleAlign: 'center',columnAlign:'center'}, |
| 56 | + {field: 'address', title: '地址', titleAlign: 'center',columnAlign:'left'} |
| 57 | + ] |
| 58 | + } |
| 59 | + } |
| 60 | + }) |
| 61 | +</script> |
| 62 | +</html> |
| 63 | +``` |
| 64 | + |
| 65 | +### NPM 方式使用 |
| 66 | + |
| 67 | +```javascript |
| 68 | +npm install vue-easytable --save-dev |
| 69 | +``` |
| 70 | + |
| 71 | +### 使用 |
| 72 | + |
| 73 | +```javascript |
| 74 | +// 引入样式 |
| 75 | +import 'vue-easytable/libs/themes-base/index.css' |
| 76 | +// 导入 table 和 分页组件 |
| 77 | +import {VTable,VPagination} from 'vue-easytable' |
| 78 | + |
| 79 | +// 注册到全局 |
| 80 | +Vue.component(VTable.name, VTable) |
| 81 | +Vue.component(VPagination.name, VPagination) |
| 82 | +``` |
0 commit comments