提交 eaf623c1 编写于 作者: D dolymood

select support auto watch texts

上级 0f5e8bff
......@@ -79,6 +79,18 @@
},
selectedText() {
return this.valueIndex !== -1 ? this.adaptOptions[0][this.valueIndex].text : ''
},
txts() {
return {
title: this.title,
confirmTxt: this.confirmTxt,
cancelTxt: this.cancelTxt
}
}
},
watch: {
txts() {
this.updatePicker()
}
},
created() {
......@@ -94,6 +106,9 @@
this.autoPop && this.showPicker()
},
methods: {
updatePicker() {
this.picker.$updateProps(this.txts)
},
showPicker() {
if (this.disabled) {
return
......
import Vue from 'vue2'
import Select from '@/modules/select'
import instantiateComponent from '@/common/helpers/instantiate-component'
import createVue from '../utils/create-vue'
describe('Select.vue', () => {
let vm
......@@ -27,6 +28,34 @@ describe('Select.vue', () => {
.to.equal('2016')
})
it('should render correct contents - update txt', (done) => {
vm = createVue({
template: `
<cube-select v-model="value" :options="options" :title="title" :confirmTxt="confirmTxt" :cancelTxt="cancelTxt" />
`,
data: {
value: 2016,
options: [2013, 2014, 2015, 2016, 2017, 2018],
title: 'title',
confirmTxt: 'confirm',
cancelTxt: 'cancel'
}
})
// change txt
vm.$parent.title = 'title2'
vm.$parent.confirmTxt = 'confirm2'
vm.$parent.cancelTxt = 'cancel2'
vm.$nextTick(() => {
expect(vm.picker.$el.querySelector('.cube-picker-choose [data-action="cancel"]').textContent.trim())
.to.equal('cancel2')
expect(vm.picker.$el.querySelector('.cube-picker-choose [data-action="confirm"]').textContent.trim())
.to.equal('confirm2')
expect(vm.picker.$el.querySelector('.cube-picker-choose h1').textContent.trim())
.to.equal('title2')
done()
})
})
it('should trigger events', function (done) {
this.timeout(10000)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册