代码如下:
<view class="select-color">
<input type="hidden" v-model="item.value" style="height: 0px; line-height: 0px;min-height:0px">
<view
:title="colorTitle"
style="{'background-color': (item.value !=='' || item.valur !== null) ? item.value : 'transparent','width':'40px','height':'40px','border':'1px solid #ec
ecec','borderRadius':'3px'}"
@click="openColorPicker(val,index)"
>
</view>
</view>
<uv-pick-color ref="ColorPicker" :color="color" @confirm.stop="(e)=>confirm(e)" :prefab-color="[]" @touchmove.native.prevent.stop></uv-pick-color>
<script>
// 调出颜色选择器
const openColorPicker = (val,index) =>{
state.idx = index
currentInstance.ctx._.refs.ColorPicker.open();
}
// 颜色选择器保留rgba形式
const confirm = (e) => {
props.options.items[state.idx].value = 'rgba(' + e.rgba.r + ',' + e.rgba.g + ',' + e.rgba.b + ',' + e.rgba.a + ')'
}
</script>