File tree Expand file tree Collapse file tree 4 files changed +93
-1
lines changed Expand file tree Collapse file tree 4 files changed +93
-1
lines changed Original file line number Diff line number Diff line change 1+ <template >
2+ <lai-render-less-comp :value =" tags" >
3+ <div slot-scope =" {tags, addTag, delTag}" class =" tags-input__wrapper" >
4+ <div class =" tags-input" >
5+ <input type =" text" @keydown.enter =" addTag" >
6+ </div >
7+
8+ <ul >
9+ <li v-for =" (tag, i) in tags" :key =" i" >{{tag}} <span @click =" delTag(i)" >× ; </span ></li >
10+ </ul >
11+ </div >
12+ </lai-render-less-comp >
13+ </template >
14+ <script >
15+ export default {
16+ data () {
17+ return {
18+ tags: [' 法国' , ' 日本' ]
19+ }
20+ }
21+ }
22+ </script >
23+ <style lang="less" scoped>
24+ .tags-input__wrapper {
25+ margin : 0 auto ;
26+ ul {
27+ margin : 10px 0 ;
28+ padding : 0 ;
29+ li {
30+ display : inline-block ;
31+ margin-right : 10px ;
32+ padding : 6px 8px ;
33+ background-color : #4dc298 ;
34+ border-radius : 4px ;
35+ list-style : none ;
36+ span {
37+ cursor : pointer ;
38+ }
39+ }
40+ }
41+ }
42+ .tags-input {
43+ display : inline-block ;
44+ padding : 10px 16px ;
45+ border : 1px solid #d6d5d5 ;
46+ border-radius : 4px ;
47+ background-color : #fff ;
48+ input {
49+ width : 300px ;
50+ height : 23px ;
51+ display : inline-block ;
52+ vertical-align : top ;
53+ border : 0 ;
54+ letter-spacing : 1.6px ;
55+ & :focus {
56+ outline : none ;
57+ }
58+ }
59+ }
60+ </style >
61+
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import Table from './pages/table.vue'
1212import Tree from './pages/tree.vue'
1313import Date from './pages/date.vue'
1414import InputTags from './pages/InputTags.vue'
15+ import RenderLessComp from './pages/renderLessComp.vue'
1516
1617Vue . use ( Router )
1718
@@ -59,6 +60,10 @@ const routes = [
5960 {
6061 path : '/input-tags' ,
6162 component : InputTags
63+ } ,
64+ {
65+ path : '/render-less' ,
66+ component : RenderLessComp
6267 }
6368]
6469
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import Table from './table'
1616import Tree from './tree'
1717import Slider from './slider'
1818import InputTags from './inputTags'
19+ import RenderLessComp from './inputTags/renderLessComp'
1920
2021export default {
2122 Switch,
@@ -34,5 +35,6 @@ export default {
3435 Alert,
3536 Tree,
3637 Slider,
37- InputTags
38+ InputTags,
39+ RenderLessComp
3840}
Original file line number Diff line number Diff line change 1+ <script >
2+ export default {
3+ props: [' value' ],
4+ methods: {
5+ addTag (e ) {
6+ let value = e .target .value .trim ()
7+ if (! this .value .includes (value)) {
8+ this .value .push (value)
9+ }
10+ e .target .value = ' '
11+ },
12+ delTag (index ) {
13+ this .value .splice (index, 1 )
14+ }
15+ },
16+ render () {
17+ return this .$scopedSlots .default ({
18+ tags: this .value ,
19+ addTag: this .addTag ,
20+ delTag: this .delTag
21+ })
22+ }
23+ }
24+ </script >
You can’t perform that action at this time.
0 commit comments