提交 d9cedce2 编写于 作者: D DCloud_LXH

chore: showToast add error type

上级 15d6373d
......@@ -3,11 +3,12 @@ import { elemInArray } from '../../helpers/protocol'
export const API_SHOW_TOAST = 'showToast'
export type API_TYPE_SHOW_TOAST = typeof uni.showToast
export type API_TYPE_SHOW_TOAST_ICON = 'success' | 'loading' | 'none'
export type API_TYPE_SHOW_TOAST_ICON = 'success' | 'loading' | 'none' | 'error'
export const SHOW_TOAST_ICON: API_TYPE_SHOW_TOAST_ICON[] = [
'success',
'loading',
'none',
'error',
]
export const ShowToastProtocol: ApiProtocol<API_TYPE_SHOW_TOAST> = {
......
......@@ -12,6 +12,7 @@ import {
onEventPrevent,
createSvgIconVNode,
ICON_PATH_SUCCESS_NO_CIRCLE,
ICON_PATH_WARN,
} from '@dcloudio/uni-core'
import {
initI18nShowToastMsgsOnce,
......@@ -94,16 +95,27 @@ export default /*#__PURE__*/ defineComponent({
})
function useToastIcon(props: ToastProps) {
const Icon = computed(() =>
props.icon === 'success' ? (
createVNode(createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, '#fff', 38), {
class: ToastIconClassName,
})
) : props.icon === 'loading' ? (
// @ts-ignore
<i class={ToastIconClassName} class="uni-loading"></i>
) : null
)
const Icon = computed(() => {
switch (props.icon) {
case 'success':
return createVNode(
createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, '#fff', 38),
{
class: ToastIconClassName,
}
)
case 'error':
return createVNode(createSvgIconVNode(ICON_PATH_WARN, '#fff', 38), {
class: ToastIconClassName,
})
case 'loading':
// @ts-ignore
return <i class={ToastIconClassName} class="uni-loading"></i>
default:
return null
}
})
return {
Icon,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册