Skip to content

Commit

Permalink
修复select无法父组件传值 选中问题
Browse files Browse the repository at this point in the history
  • Loading branch information
monw3c committed Jul 5, 2018
1 parent 59d37cc commit 8c5965c
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1"><title>xmui - 基于vue2,可复用UI组件</title><link href=./static/css/app.26aa33ebb2f13ce3c51ad0b65c333975.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.5261056b2a2138af8b95.js></script><script type=text/javascript src=./static/js/vendor.c7ad6fdac84180d296de.js></script><script type=text/javascript src=./static/js/app.46dc9966c99cbd0ee925.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1"><title>xmui - 基于vue2,可复用UI组件</title><link href=./static/css/app.26aa33ebb2f13ce3c51ad0b65c333975.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.2927785900ec46c102be.js></script><script type=text/javascript src=./static/js/vendor.c7ad6fdac84180d296de.js></script><script type=text/javascript src=./static/js/app.05bac464c56b905df19a.js></script></body></html>
2 changes: 2 additions & 0 deletions docs/dist/static/js/0.a6f54f3a647ea2a5bc29.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/dist/static/js/0.a6f54f3a647ea2a5bc29.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/dist/static/js/0.eecdedcb81e6032983f5.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/dist/static/js/0.eecdedcb81e6032983f5.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions docs/dist/static/js/app.05bac464c56b905df19a.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/dist/static/js/app.05bac464c56b905df19a.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/dist/static/js/app.46dc9966c99cbd0ee925.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/dist/static/js/app.46dc9966c99cbd0ee925.js.map

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "x-m-ui",
"version": "0.1.38",
"version": "0.1.39",
"description": "UI components base on Vue 2.x",
"author": "mon <505038730@qq.com>",
"main": "package/xmui.min.js",
Expand Down
21 changes: 17 additions & 4 deletions package/comps/components/select/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,35 @@
export default {
name: 'xm-select',
props: {
data: [Array],
data: {
type: Array,
required: true
},
right: {
type: Boolean,
default: false
}
},
value: [String, Number, Object, Boolean],
},
data () {
return {
selectVal: 0
selectVal: ''
}
},
watch: {
value (val) {
this.selectVal = val
},
selectVal (val) {
this.$emit('change', val)
this.$emit('input', val)
}
},
created () {
if (typeof this.value !== 'undefined') {
this.selectVal = this.value
}
}
},
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion package/xmui.min.js

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions src/comps/components/select/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,35 @@
export default {
name: 'xm-select',
props: {
data: [Array],
data: {
type: Array,
required: true
},
right: {
type: Boolean,
default: false
}
},
value: [String, Number, Object, Boolean],
},
data () {
return {
selectVal: 0
selectVal: ''
}
},
watch: {
value (val) {
this.selectVal = val
},
selectVal (val) {
this.$emit('change', val)
this.$emit('input', val)
}
},
created () {
if (typeof this.value !== 'undefined') {
this.selectVal = this.value
}
}
},
}
</script>

Expand Down
7 changes: 4 additions & 3 deletions src/views/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
<xm-textarea slot="right" placeholder="请输入留言,50字以内" :value="value" @input="textareaAction" max="50"></xm-textarea>
</xm-cell-item>
<xm-cell-item>
<xm-select slot="right" :data="selectList" @change="selectAction"></xm-select>
<xm-select slot="right" :data="selectList" @change="selectAction" v-model="curSelected"></xm-select>
<span slot="rightIcon" class="xm__icon--right"></span>
</xm-cell-item>
<xm-cell-item>
<span slot="left">出行方式</span>
<xm-select slot="right" right :data="selectList"></xm-select>
<xm-select slot="right" right :data="selectList" v-model="curSelected"></xm-select>
<span slot="rightIcon" class="xm__icon--right"></span>
</xm-cell-item>
<xm-flexbox>
Expand Down Expand Up @@ -547,6 +547,7 @@ export default {
{ name: '出租车', value: 5 },
{ name: '代驾', value: 6 }
],
curSelected: '3',
inputVal: '',
textareaVal: '',
selectVal: '',
Expand Down Expand Up @@ -667,7 +668,7 @@ export default {
})
},
btnClick () {
alert('按钮点击')
},
closeTag () {
this.tag1 = false
Expand Down

0 comments on commit 8c5965c

Please sign in to comment.