66 | { this.$slots.text ? this.$slots.text :
{this.selectedText}
}
67 | {
68 | this.showMenu
69 | ?
70 | {this.options.map(item => {
71 | if (item.value === this.value) {
72 | return - {item.children || item.text}
73 | } else {
74 | return - {item.children || item.text}
75 | }
76 | })}
77 |
78 | : ''
79 | }
80 |
81 | },
82 | watch: {
83 | value (newVal, oldVal) {
84 | // todo
85 | setTimeout(() => {
86 | this.update(newVal)
87 | }, 1000)
88 | }
89 | },
90 | mounted () {
91 | this.update(this.value)
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/components/select/index.js:
--------------------------------------------------------------------------------
1 | import Select from './Select.js'
2 | import SelectItem from './Item.vue'
3 | export {Select, SelectItem}
4 |
--------------------------------------------------------------------------------
/src/components/select/select.less:
--------------------------------------------------------------------------------
1 | .pop-select{
2 | display: inline-block;
3 | position: relative;
4 |
5 | .select-value{
6 | padding: 2px 10px;
7 | background-color: #f0f0f0;
8 | border-radius: 4px;
9 | }
10 | .pop-option{
11 | position: absolute;
12 | left: 0;
13 | top: 30px;
14 | width: 200px;
15 | max-height: 300px;
16 | overflow-x: hidden;
17 | background-color: #fff;
18 | box-shadow: 0 0 10px #ccc;
19 | z-index: 999;
20 | border-radius: 4px;
21 |
22 | li{
23 | padding: 10px;
24 | }
25 | li:hover{
26 | background-color: #f5f5f5;
27 | cursor: pointer;
28 | }
29 | li.active{
30 | background-color: #f0f0f0;
31 | }
32 | }
33 | .pop-option.right{
34 | left: auto;
35 | right: 0;
36 | }
37 | }
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |