|
7 | 7 | }) |
8 | 8 | </script> |
9 | 9 |
|
10 | | -<script> |
11 | | - const $table = $('#table') |
12 | | - |
13 | | - function mounted () { |
14 | | - $('label input').blur(function () { |
15 | | - const icons = {} |
16 | | - |
17 | | - $('label').each(function () { |
18 | | - icons[$(this).find('span').text()] = $(this).find('input').val() |
19 | | - }) |
20 | | - $table.bootstrapTable('destroy').bootstrapTable({ |
21 | | - icons |
22 | | - }) |
23 | | - }) |
24 | | - } |
25 | | -</script> |
26 | | - |
27 | 10 | <template> |
28 | 11 | <div> |
29 | | - <label><span>paginationSwitchDown</span> <input |
| 12 | + <label class="icon-label"><span>paginationSwitchDown</span> <input |
30 | 13 | class="form-control" |
31 | 14 | type="text" |
32 | 15 | value="fa-caret-square-down" |
33 | 16 | ></label> |
34 | 17 | </div> |
35 | 18 | <div> |
36 | | - <label><span>paginationSwitchUp</span> <input |
| 19 | + <label class="icon-label"><span>paginationSwitchUp</span> <input |
37 | 20 | class="form-control" |
38 | 21 | type="text" |
39 | 22 | value="fa-caret-square-up" |
40 | 23 | ></label> |
41 | 24 | </div> |
42 | 25 | <div> |
43 | | - <label><span>refresh</span> <input |
| 26 | + <label class="icon-label"><span>refresh</span> <input |
44 | 27 | class="form-control" |
45 | 28 | type="text" |
46 | 29 | value="fa-sync" |
47 | 30 | ></label> |
48 | 31 | </div> |
49 | 32 | <div> |
50 | | - <label><span>toggleOff</span> <input |
| 33 | + <label class="icon-label"><span>toggleOff</span> <input |
51 | 34 | class="form-control" |
52 | 35 | type="text" |
53 | 36 | value="fa-toggle-off" |
54 | 37 | ></label> |
55 | 38 | </div> |
56 | 39 | <div> |
57 | | - <label><span>toggleOn</span> <input |
| 40 | + <label class="icon-label"><span>toggleOn</span> <input |
58 | 41 | class="form-control" |
59 | 42 | type="text" |
60 | 43 | value="fa-toggle-on" |
61 | 44 | ></label> |
62 | 45 | </div> |
63 | 46 | <div> |
64 | | - <label><span>columns</span> <input |
| 47 | + <label class="icon-label"><span>columns</span> <input |
65 | 48 | class="form-control" |
66 | 49 | type="text" |
67 | 50 | value="fa-th-list" |
68 | 51 | ></label> |
69 | 52 | </div> |
70 | 53 | <div> |
71 | | - <label><span>fullscreen</span> <input |
| 54 | + <label class="icon-label"><span>fullscreen</span> <input |
72 | 55 | class="form-control" |
73 | 56 | type="text" |
74 | 57 | value="fa-arrows-alt" |
75 | 58 | ></label> |
76 | 59 | </div> |
77 | 60 | <div> |
78 | | - <label><span>detailOpen</span> <input |
| 61 | + <label class="icon-label"><span>detailOpen</span> <input |
79 | 62 | class="form-control" |
80 | 63 | type="text" |
81 | 64 | value="fa-plus" |
82 | 65 | ></label> |
83 | 66 | </div> |
84 | 67 |
|
85 | 68 | <div> |
86 | | - <label><span>detailClose</span> <input |
| 69 | + <label class="icon-label"><span>detailClose</span> <input |
87 | 70 | class="form-control" |
88 | 71 | type="text" |
89 | 72 | value="fa-minus" |
|
92 | 75 |
|
93 | 76 | <table |
94 | 77 | id="table" |
95 | | - data-toggle="table" |
96 | 78 | data-height="460" |
97 | 79 | data-show-pagination-switch="true" |
98 | 80 | data-show-refresh="true" |
|
118 | 100 | </table> |
119 | 101 | </template> |
120 | 102 |
|
| 103 | +<script> |
| 104 | + const $table = $('#table') |
| 105 | + |
| 106 | + function mounted () { |
| 107 | + const getIconsOptions = () => { |
| 108 | + const icons = {} |
| 109 | + |
| 110 | + $('label.icon-label').each(function () { |
| 111 | + icons[$(this).find('span').text()] = $(this).find('input').val() |
| 112 | + }) |
| 113 | + |
| 114 | + return { |
| 115 | + iconsPrefix: 'fa', |
| 116 | + icons |
| 117 | + } |
| 118 | + } |
| 119 | + |
| 120 | + $('label.icon-label input').blur(function () { |
| 121 | + $table.bootstrapTable('destroy').bootstrapTable(getIconsOptions()) |
| 122 | + }) |
| 123 | + |
| 124 | + $table.bootstrapTable(getIconsOptions()) |
| 125 | + } |
| 126 | +</script> |
| 127 | + |
121 | 128 | <style> |
122 | 129 | label input { |
123 | 130 | display: inline-block !important; |
|
0 commit comments