From 6a9046adbdac502e3df63bbd8e196f4b1a7a585f Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Thu, 02 Dec 2021 10:14:52 +0800 Subject: [PATCH] 增加按钮可用颜色 --- forms/select/CSelect.vue | 61 ++++++++++++++++++------------ 1 files changed, 37 insertions(+), 24 deletions(-) diff --git a/forms/select/CSelect.vue b/forms/select/CSelect.vue index cf02769..9270195 100644 --- a/forms/select/CSelect.vue +++ b/forms/select/CSelect.vue @@ -5,27 +5,37 @@ <template> <view class="c-select"> - <picker + <!-- 下拉选择模式 --> + <view v-if="!selectByPage" - mode="selector" - :range="options" - :value="current" - range-key="name" - @change="evt=>handleChange(evt.detail)" + class="c-select-slot-mode" > - <AtInput - ref="input" - :name="itemRes.name" - :title="itemRes.label" - :required="itemRes.required" - :disabled="itemRes.disabled" - :error="itemRes.error" - :placeholder="placeholder" - :value="selected" + <picker + class="c-select-input" + mode="selector" + :range="options" + :value="current" + range-key="name" + @change="evt=>handleChange(evt.detail)" > - <view class="at-icon at-icon-chevron-right" /> - </AtInput> - </picker> + <AtInput + ref="input" + :name="itemRes.name" + :title="itemRes.label" + :required="itemRes.required" + :disabled="itemRes.disabled" + :error="itemRes.error" + :placeholder="placeholder" + :value="selected" + > + <view class="at-icon at-icon-chevron-right" /> + </AtInput> + </picker> + <view class="c-select-slot"> + <slot /> + </view> + </view> + <!-- 跳转页面模式 --> <view v-else-if="selectByPage.length > 5" @tap="evt => onGoToSelectorPage()" @@ -111,18 +121,21 @@ } else { url += '?mode=CSelect'; } - const eventor = $pagePoster.createEventor(); - eventor.on('@linked', () => { - eventor.emit('lastValue', this.choose.value); + if (this._eventor) { + // 销毁上次事件收发器 + this._eventor.destroy(); + } + this._eventor = $pagePoster.createEventor(); + this._eventor.on('@linked', () => { + this._eventor.emit('lastValue', this.choose.value); }); - eventor.on('selected', data => { + this._eventor.on('selected', data => { this.choose.name = data.name; this.choose.value = data.value; this.itemRes.onChange(data.value); this.onSelectFromPage && this.onSelectFromPage(data.value); - eventor.destroy(); }); - Taro.navigateTo({ url: url + '&eventorId=' + eventor.id }); + Taro.navigateTo({ url: url + '&eventorId=' + this._eventor.id }); }, }, }; -- Gitblit v1.9.1