提交 873141ba 编写于 作者: D DCloud_LXH

chore: 处理 warning

上级 a4b9d0a6
<script lang="uts"> <script lang="uts">
export type ItemType = { value : number; name : string } export type ItemType = { value : number; name : string }
export default { export default {
props: { props: {
title: { title: {
type: String, type: String,
default: '' default: ''
}, },
items: { items: {
type: Array as PropType<Array<ItemType>>, type: Array as PropType<Array<ItemType>>,
required: true required: true
} }
}, },
data() { data() {
return { return {
current: 0 current: 0
} }
}, },
methods: { methods: {
// @ts-ignore // @ts-ignore
_change(e : RadioGroupChangeEvent) { _change(e : RadioGroupChangeEvent) {
const selected = this.items.find((item) : boolean => { const selected = this.items.find((item: ItemType) : boolean => {
return item.name === e.detail.value as string return item.name === e.detail.value
}) }) as ItemType | null
this.current = selected?.value as number if (selected !== null) {
this.$emit('change', this.current) this.current = selected.value
uni.showToast({ this.$emit('change', this.current)
icon: 'none', uni.showToast({
title: '当前选中:' + selected?.name, icon: 'none',
}) title: '当前选中:' + selected.name,
} })
} }
} }
}
}
</script> </script>
<template> <template>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<view class="uni-title uni-common-mt"> <view class="uni-title uni-common-mt">
<text class="uni-title-text"> {{title}} </text> <text class="uni-title-text"> {{title}} </text>
</view> </view>
</view> </view>
<view class="uni-list uni-common-pl"> <view class="uni-list uni-common-pl">
<radio-group @change="_change" class="radio-group"> <radio-group @change="_change" class="radio-group">
<radio class="uni-list-cell uni-list-cell-pd radio" v-for="(item, index) in items" :key="item.name" <radio class="uni-list-cell uni-list-cell-pd radio" v-for="(item, index) in items" :key="item.name"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.name" :checked="index === current"> :class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item.name" :checked="index === current">
{{ item.name }} {{ item.name }}
</radio> </radio>
</radio-group> </radio-group>
</view> </view>
</template> </template>
<style></style> <style></style>
\ No newline at end of file
...@@ -48,10 +48,6 @@ ...@@ -48,10 +48,6 @@
this.showClearIcon = false this.showClearIcon = false
this.$emit('confirm', this.getValue(this.inputClearValue)) this.$emit('confirm', this.getValue(this.inputClearValue))
}, },
// @ts-ignore
confirm(e : InputConfirmEvent) {
// this.$emit('confirm', this.getValue(e.detail.value))
},
blur() { blur() {
this.showClearIcon = false this.showClearIcon = false
}, },
...@@ -85,8 +81,7 @@ ...@@ -85,8 +81,7 @@
</view> </view>
</view> </view>
<view class="uni-input-wrapper input-wrapper"> <view class="uni-input-wrapper input-wrapper">
<input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" @input="input" <input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" @input="input" @blur="blur" @focus="focus" />
@confirm="confirm" @blur="blur" @focus="focus" />
<image class="input-wrapper_image" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon"> <image class="input-wrapper_image" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon">
</image> </image>
</view> </view>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册