Skip to content

Commit 3ca7ec0

Browse files
committed
添加input-tags组件
1 parent 14680d2 commit 3ca7ec0

File tree

8 files changed

+131
-9
lines changed

8 files changed

+131
-9
lines changed

docs/.vuepress/config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,5 @@ module.exports = {
4747
config.output.publicPath =
4848
process.env.NODE_ENV === "production" ? "/lai-ui/" : "/"
4949
}
50-
console.log(config)
5150
}
5251
}

docs/posts/tutorial/5.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
# 无渲染组件
1+
# 无渲染组件
2+

examples/app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div id="app">
33
<!-- <img class="avatar" src="../src/assets/images/cache_user_icon.jpg" alt=""> -->
44
<router-view></router-view>
5-
<lai-button @click.native="openModal">Modal</lai-button>
5+
<!-- <lai-button @click.native="openModal">Modal</lai-button> -->
66
</div>
77
</template>
88

examples/pages/inputTags.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<div class="input-tag__wrapper">
3+
<lai-input-tags :tags="tags" @on-change="handleChangeTags"></lai-input-tags>
4+
</div>
5+
</template>
6+
<script>
7+
export default {
8+
data () {
9+
return {
10+
tags: [
11+
'日本',
12+
'泰国'
13+
]
14+
}
15+
},
16+
methods: {
17+
handleChangeTags (cur, tags) {
18+
console.log(cur, tags)
19+
}
20+
}
21+
}
22+
</script>

examples/routes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ImgLoader from './pages/imgLoader.vue'
1111
import Table from './pages/table.vue'
1212
import Tree from './pages/tree.vue'
1313
import Date from './pages/date.vue'
14+
import InputTags from './pages/InputTags.vue'
1415

1516
Vue.use(Router)
1617

@@ -54,6 +55,10 @@ const routes = [
5455
{
5556
path: '/date',
5657
component: Date
58+
},
59+
{
60+
path: '/input-tags',
61+
component: InputTags
5762
}
5863
]
5964

src/components/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Alert from './alert'
1515
import Table from './table'
1616
import Tree from './tree'
1717
import Slider from './slider'
18+
import InputTags from './inputTags'
1819

1920
export default {
2021
Switch,
@@ -32,5 +33,6 @@ export default {
3233
CheckboxGroup,
3334
Alert,
3435
Tree,
35-
Slider
36+
Slider,
37+
InputTags
3638
}

src/components/inputTags/index.vue

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<template>
2+
<div class="input-tag">
3+
<span class="tag" v-for="(tag, i) in tags" :key="i">
4+
{{tag}}
5+
<a href="javascript:;" @click="delTag(i)">&times;</a>
6+
</span>
7+
<input type="text" @keydown.enter="addTag">
8+
</div>
9+
</template>
10+
11+
<script>
12+
export default {
13+
props: {
14+
tags: Array
15+
},
16+
mounted () {
17+
console.log(this.tags)
18+
},
19+
methods: {
20+
addTag (e) {
21+
let value = e.target.value.trim()
22+
if (!this.tags.includes(value)) {
23+
this.tags.push(value)
24+
}
25+
e.target.value = ''
26+
this.$emit('on-change',value, this.tags)
27+
},
28+
delTag (index) {
29+
this.tags.splice(index, 1)
30+
}
31+
}
32+
}
33+
</script>
34+
<style lang="less" scoped>
35+
.input-tag {
36+
position: absolute;
37+
top: 50%;
38+
left: 50%;
39+
transform: translate(-50%, -5%);
40+
display: inline-block;
41+
padding: 10px 16px;
42+
border: 1px solid #d6d5d5;
43+
border-radius: 4px;
44+
background-color: #fff;
45+
}
46+
47+
.input-tag .tag {
48+
display: inline-block;
49+
margin-right: 10px;
50+
padding: 3px 5px;
51+
background-color: #41c5b4;
52+
font-size: 13px;
53+
color: #fff;
54+
border-radius: 4px;
55+
}
56+
57+
.input-tag .tag a {
58+
display: inline-block;
59+
vertical-align: 1px;
60+
text-decoration: none;
61+
color: #00000091;
62+
font-size: 14px;
63+
}
64+
65+
.input-tag input {
66+
width: 300px;
67+
height: 23px;
68+
display: inline-block;
69+
vertical-align: top;
70+
border: 0;
71+
letter-spacing: 1.6px;
72+
}
73+
.input-tag input:focus {
74+
outline: none;
75+
}
76+
</style>
77+

yarn.lock

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5116,9 +5116,10 @@ markdown-it-table-of-contents@^0.4.0:
51165116
version "0.4.3"
51175117
resolved "http://registry.npm.taobao.org/markdown-it-table-of-contents/download/markdown-it-table-of-contents-0.4.3.tgz#6453925a76e49b9b3d9569a0d89f1c2168b46982"
51185118

5119-
markdown-it@^8.4.1:
5119+
markdown-it@^8.4.1, markdown-it@^8.4.2:
51205120
version "8.4.2"
5121-
resolved "http://registry.npm.taobao.org/markdown-it/download/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
5121+
resolved "https://registry.npm.taobao.org/markdown-it/download/markdown-it-8.4.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmarkdown-it%2Fdownload%2Fmarkdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
5122+
integrity sha1-OG+YmY3BWjdyKqdyIIT0Agvdm1Q=
51225123
dependencies:
51235124
argparse "^1.0.7"
51245125
entities "~1.1.1"
@@ -8000,6 +8001,20 @@ vue-server-renderer@^2.5.16:
80008001
serialize-javascript "^1.3.0"
80018002
source-map "0.5.6"
80028003

8004+
vue-server-renderer@^2.5.17:
8005+
version "2.6.10"
8006+
resolved "https://registry.npm.taobao.org/vue-server-renderer/download/vue-server-renderer-2.6.10.tgz#cb2558842ead360ae2ec1f3719b75564a805b375"
8007+
integrity sha1-yyVYhC6tNgri7B83GbdVZKgFs3U=
8008+
dependencies:
8009+
chalk "^1.1.3"
8010+
hash-sum "^1.0.2"
8011+
he "^1.1.0"
8012+
lodash.template "^4.4.0"
8013+
lodash.uniq "^4.5.0"
8014+
resolve "^1.2.0"
8015+
serialize-javascript "^1.3.0"
8016+
source-map "0.5.6"
8017+
80038018
vue-style-loader@^4.1.0, vue-style-loader@^4.1.2:
80048019
version "4.1.2"
80058020
resolved "http://registry.npm.taobao.org/vue-style-loader/download/vue-style-loader-4.1.2.tgz#dedf349806f25ceb4e64f3ad7c0a44fba735fcf8"
@@ -8049,9 +8064,10 @@ vuepress-html-webpack-plugin@^3.2.0:
80498064
toposort "^1.0.0"
80508065
util.promisify "1.0.0"
80518066

8052-
vuepress@^0.14.9:
8053-
version "0.14.10"
8054-
resolved "http://registry.npm.taobao.org/vuepress/download/vuepress-0.14.10.tgz#070281ad0c9d48e7c848eb9511c96ceb106414ab"
8067+
vuepress@^0.14.10:
8068+
version "0.14.11"
8069+
resolved "https://registry.npm.taobao.org/vuepress/download/vuepress-0.14.11.tgz#fc6ba0e609e3433a8070e95301b4d987712b2a08"
8070+
integrity sha1-/Gug5gnjQzqAcOlTAbTZh3ErKgg=
80558071
dependencies:
80568072
"@babel/core" "7.0.0-beta.47"
80578073
"@vue/babel-preset-app" "3.0.0-beta.11"

0 commit comments

Comments
 (0)