diff --git a/packages/notify/index.less b/packages/notify/index.less index 265b1305..c7a5bf5e 100644 --- a/packages/notify/index.less +++ b/packages/notify/index.less @@ -3,7 +3,6 @@ .van-notify { position: fixed; top: 0; - z-index: 110; width: 100%; padding: @notify-padding; font-size: @notify-font-size; diff --git a/packages/notify/index.ts b/packages/notify/index.ts index ae34bc33..b953d79b 100644 --- a/packages/notify/index.ts +++ b/packages/notify/index.ts @@ -18,6 +18,10 @@ VantComponent({ duration: { type: Number, value: 3000 + }, + zIndex: { + type: Number, + value: 110 } }, diff --git a/packages/notify/index.wxml b/packages/notify/index.wxml index 4f480eaa..96f58206 100644 --- a/packages/notify/index.wxml +++ b/packages/notify/index.wxml @@ -2,7 +2,7 @@ name="slide-down" show="{{ show }}" custom-class="van-notify" - custom-style="background-color:{{ backgroundColor }}; color: {{ color }};" + custom-style="background-color:{{ backgroundColor }}; color: {{ color }}; z-index: {{ zIndex }};" > {{ text }} diff --git a/packages/notify/notify.ts b/packages/notify/notify.ts index dcc23b64..dfefe98a 100644 --- a/packages/notify/notify.ts +++ b/packages/notify/notify.ts @@ -1,6 +1,6 @@ import { isObj } from '../common/utils'; -type NotifyOptions = { +interface NotifyOptions { text: string; color?: string; backgroundColor?: string; @@ -8,7 +8,8 @@ type NotifyOptions = { selector?: string; context?: any; safeAreaInsetTop?: boolean; -}; + zIndex?: number; +} const defaultOptions = { selector: '#van-notify', @@ -16,10 +17,10 @@ const defaultOptions = { }; function parseOptions(text: NotifyOptions | string): NotifyOptions { - return isObj(text) ? text as NotifyOptions : { text } as NotifyOptions; + return isObj(text) ? (text as NotifyOptions) : ({ text } as NotifyOptions); } -function getContext() { +function getContext(): Page.PageInstance { const pages = getCurrentPages(); return pages[pages.length - 1]; }