3131 v-for =" tag in tags"
3232 :key =" tag.name"
3333 closable
34+ @close =" handleCloseTag(tag)"
3435 :type =" tag.type" >
3536 {{tag.name}}
3637 </el-tag >
5859 </el-tag >
5960 <el-input
6061 class =" input-new-tag"
61- v-if =" inputVisible"
6262 v-model =" inputValue"
63+ v-if =" inputVisible"
6364 ref =" saveTagInput"
6465 size =" small"
6566 @keyup.enter.native =" handleInputConfirm"
6667 @blur =" handleInputConfirm"
6768 >
6869 </el-input >
69- <el-button v-else class =" button-new-tag" size =" small" @click =" showInput" >+ New Tag</el-button >
70+ <i v-else class =" el-icon-circle-plus button-new-tag" @click =" showInput" ></i >
71+ <!-- <el-button class="button-new-tag" size="small" @click="showInput">+ New Tag</el-button> -->
7072 </div >
7173 </el-row >
7274 <el-collapse class =" test" style =" color :red ;" >
@@ -127,6 +129,7 @@ export default {
127129 v-for="tag in tags"
128130 :key="tag.name"
129131 closable
132+ @close="handleCloseTag(tag)"
130133 :type="tag.type">
131134 {{tag.name}}
132135 </el-tag>
@@ -143,6 +146,10 @@ export default {
143146 { name: '标签五', type: 'danger' }
144147 ]
145148 };
149+ methods: {
150+ handleCloseTag(tag) {
151+ this.tags.splice(this.tags.indexOf(tag), 1);
152+ },
146153 }
147154 }
148155 <\/ script>` ,
@@ -183,6 +190,9 @@ export default {
183190 margin-left: 10px;
184191 vertical-align: bottom;
185192 }
193+ .input-new-tag /deep/ .el-input__inner {
194+ height: 24px;
195+ }
186196 </style>
187197
188198 <script>
@@ -233,6 +243,17 @@ export default {
233243 this .init ()
234244 },
235245 methods: {
246+ handleInputConfirm () {
247+ let inputValue = this .inputValue ;
248+ if (inputValue) {
249+ this .dynamicTags .push (inputValue);
250+ }
251+ this .inputVisible = false ;
252+ this .inputValue = ' ' ;
253+ },
254+ handleCloseTag (tag ) {
255+ this .tags .splice (this .tags .indexOf (tag), 1 )
256+ },
236257 handleClose (tag ) {
237258 this .dynamicTags .splice (this .dynamicTags .indexOf (tag), 1 )
238259 },
@@ -254,15 +275,20 @@ export default {
254275 margin-left : 10px ;
255276}
256277.button-new-tag {
278+ cursor : pointer ;
279+ vertical-align : middle ;
280+ color : #3963BC ;
257281 margin-left : 10px ;
258- height : 32px ;
259- line-height : 30px ;
260- padding-top : 0 ;
261- padding-bottom : 0 ;
282+ font-size : 24px ;
283+ height : 24px ;
284+ line-height : 24px ;
262285}
263286.input-new-tag {
264287 width : 90px ;
265288 margin-left : 10px ;
266289 vertical-align : bottom ;
267290}
291+ .input-new-tag /deep/ .el-input__inner {
292+ height : 24px ;
293+ }
268294 </style >
0 commit comments