vue中使用element-ui的例子
拷贝element-ui例子时,head中引用时可能需要注意下
1. table的例子
<html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> <script src="https://unpkg.com/element-ui@2.15.13/lib/index.js"></script> <link rel="stylesheet" href="https://unpkg.com/element-ui@2.15.13/lib/theme-chalk/index.css"> </head> <body> <div id="app"> <template> <el-table :data="tableData" stripe style="width: 100%"> <el-table-column prop="date" label="日期" width="180"> </el-table-column> <el-table-column prop="name" label="姓名" width="180"> </el-table-column> <el-table-column prop="address" label="地址"> </el-table-column> </el-table> </template> </div> </body> <script> var Main = { data() { return { tableData: [{ date: '2016-05-02', name: '王小虎', address: '上海市普陀区金沙江路 1518 弄' }, { date: '2016-05-04', name: '王小虎', address: '上海市普陀区金沙江路 1517 弄' }, { date: '2016-05-01', name: '王小虎', address: '上海市普陀区金沙江路 1519 弄' }, { date: '2016-05-03', name: '王小虎', address: '上海市普陀区金沙江路 1516 弄' }] } } } var Ctor = Vue.extend(Main) new Ctor().$mount('#app') </script>
2. dropdown的例子,data替换了下
<html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script> <script src="https://unpkg.com/element-ui@2.15.13/lib/index.js"></script> <link rel="stylesheet" href="https://unpkg.com/element-ui@2.15.13/lib/theme-chalk/index.css"> </head> <div id="app"> <el-dropdown> <el-button type="primary"> 更多菜单<i class="el-icon-arrow-down el-icon--right"></i> </el-button> <el-dropdown-menu slot="dropdown"> <el-dropdown-item v-for="food in mydata"> {{food}} </el-dropdown-item> </el-dropdown-menu> </el-dropdown> </div> <style> .el-dropdown { vertical-align: top; } .el-dropdown + .el-dropdown { margin-left: 15px; } .el-icon-arrow-down { font-size: 12px; } </style> <script> new Vue({ el: '#app', data: { mydata: ["狮子头", "黄金糕", "大鸭梨"] }, methods: { handleClick() { alert('button click') } } }) </script>
努力生活,融于自然