mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-24 11:05:17 +08:00
refactor(components): [result] switch to script-setup syntax (#7891)
This commit is contained in:
parent
1069e9ff34
commit
ce54397999
@ -35,7 +35,8 @@ export const resultProps = buildProps({
|
||||
default: '',
|
||||
},
|
||||
icon: {
|
||||
values: ['success', 'warning', 'info', 'error'],
|
||||
type: String,
|
||||
values: ['success', 'warning', 'info', 'error'] as const,
|
||||
default: 'info',
|
||||
},
|
||||
} as const)
|
||||
|
@ -24,33 +24,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from 'vue'
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { useNamespace } from '@element-plus/hooks'
|
||||
import { IconComponentMap, IconMap, resultProps } from './result'
|
||||
const COMPONENT_NAME = 'ElResult'
|
||||
export default defineComponent({
|
||||
name: COMPONENT_NAME,
|
||||
props: resultProps,
|
||||
setup(props) {
|
||||
const ns = useNamespace('result')
|
||||
|
||||
const resultIcon = computed(() => {
|
||||
const icon = props.icon
|
||||
const iconClass = icon && IconMap[icon] ? IconMap[icon] : 'icon-info'
|
||||
const iconComponent =
|
||||
IconComponentMap[iconClass] || IconComponentMap['icon-info']
|
||||
defineOptions({
|
||||
name: 'ElResult',
|
||||
})
|
||||
|
||||
return {
|
||||
class: iconClass,
|
||||
component: iconComponent,
|
||||
}
|
||||
})
|
||||
const props = defineProps(resultProps)
|
||||
|
||||
return {
|
||||
ns,
|
||||
resultIcon,
|
||||
}
|
||||
},
|
||||
const ns = useNamespace('result')
|
||||
|
||||
const resultIcon = computed(() => {
|
||||
const icon = props.icon
|
||||
const iconClass = icon && IconMap[icon] ? IconMap[icon] : 'icon-info'
|
||||
const iconComponent =
|
||||
IconComponentMap[iconClass] || IconComponentMap['icon-info']
|
||||
|
||||
return {
|
||||
class: iconClass,
|
||||
component: iconComponent,
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user