userlist.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>iview example</title>
  6. <link rel="stylesheet" type="text/css" href="http://unpkg.com/iview/dist/styles/iview.css">
  7. <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>
  8. <script type="text/javascript" src="http://unpkg.com/iview/dist/iview.min.js"></script>
  9. <style>
  10. #app{padding: 32px;}
  11. </style>
  12. </head>
  13. <body>
  14. <div id="app">
  15. <i-table border :columns="columns7" :data="data6"></i-table>
  16. </div>
  17. <script>
  18. var Main = {
  19. data () {
  20. return {
  21. columns7: [
  22. {
  23. title: 'Name',
  24. key: 'name',
  25. render: (h, params) => {
  26. return h('div', [
  27. h('Icon', {
  28. props: {
  29. type: 'person'
  30. }
  31. }),
  32. h('strong', params.row.name)
  33. ]);
  34. }
  35. },
  36. {
  37. title: 'Age',
  38. key: 'age'
  39. },
  40. {
  41. title: 'Address',
  42. key: 'address'
  43. },
  44. {
  45. title: 'Action',
  46. key: 'action',
  47. width: 150,
  48. align: 'center',
  49. render: (h, params) => {
  50. return h('div', [
  51. h('Button', {
  52. props: {
  53. type: 'primary',
  54. size: 'small'
  55. },
  56. style: {
  57. marginRight: '5px'
  58. },
  59. on: {
  60. click: () => {
  61. this.show(params.index)
  62. }
  63. }
  64. }, 'View'),
  65. h('Button', {
  66. props: {
  67. type: 'error',
  68. size: 'small'
  69. },
  70. on: {
  71. click: () => {
  72. this.remove(params.index)
  73. }
  74. }
  75. }, 'Delete')
  76. ]);
  77. }
  78. }
  79. ],
  80. data6: [
  81. {
  82. name: 'John Brown',
  83. age: 18,
  84. address: 'New York No. 1 Lake Park'
  85. },
  86. {
  87. name: 'Jim Green',
  88. age: 24,
  89. address: 'London No. 1 Lake Park'
  90. },
  91. {
  92. name: 'Joe Black',
  93. age: 30,
  94. address: 'Sydney No. 1 Lake Park'
  95. },
  96. {
  97. name: 'Jon Snow',
  98. age: 26,
  99. address: 'Ottawa No. 2 Lake Park'
  100. }
  101. ]
  102. }
  103. },
  104. methods: {
  105. show (index) {
  106. this.$Modal.info({
  107. title: 'User Info',
  108. content: `Name:${this.data6[index].name}<br>Age:${this.data6[index].age}<br>Address:${this.data6[index].address}`
  109. })
  110. },
  111. remove (index) {
  112. this.data6.splice(index, 1);
  113. }
  114. }
  115. }
  116. var Component = Vue.extend(Main)
  117. new Component().$mount('#app')
  118. </script>
  119. </body>
  120. </html>