breaking change(Notify): rename text、backgroundColor option (#1919)

This commit is contained in:
neverland 2019-08-28 11:36:10 +08:00 committed by GitHub
parent 23c2936146
commit 439efea9ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 25 deletions

View File

@ -8,3 +8,8 @@
- `BadgeGroup`重命名为`Sidebar` - `BadgeGroup`重命名为`Sidebar`
- `Badge`重命名为`SlidebarItem` - `Badge`重命名为`SlidebarItem`
##### Notify
- `text`选项重命名为`message`
- `backgroundColor`选项重命名为`background`

View File

@ -9,9 +9,9 @@ Page({
showNotify2() { showNotify2() {
Notify({ Notify({
duration: 1000, duration: 1000,
text: '通知内容', message: '通知内容',
selector: '#custom-selector', selector: '#custom-selector',
backgroundColor: '#1989fa', background: '#1989fa',
safeAreaInsetTop: true safeAreaInsetTop: true
}); });
}, },

View File

@ -11,7 +11,7 @@
"release": "sh build/release.sh", "release": "sh build/release.sh",
"release:site": "sh build/release-site.sh", "release:site": "sh build/release-site.sh",
"build:lib": "yarn && npx gulp -f build/compiler.js --series buildEs buildLib", "build:lib": "yarn && npx gulp -f build/compiler.js --series buildEs buildLib",
"build:changelog": "vant changelog --tag v0.5.0 ./docs/markdown/changelog.generated.md" "build:changelog": "vant changelog --tag v1.0.0 ./docs/markdown/changelog.generated.md"
}, },
"files": [ "files": [
"dist", "dist",

View File

@ -27,10 +27,10 @@ Notify('通知内容');
```js ```js
Notify({ Notify({
text: '通知内容', message: '通知内容',
duration: 1000, duration: 1000,
selector: '#custom-selector', selector: '#custom-selector',
backgroundColor: '#1989fa' background: '#1989fa'
}); });
``` ```
@ -42,10 +42,10 @@ Notify({
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
|-----------|-----------|-----------|-------------| |-----------|-----------|-----------|-------------|
| text | 展示文案 | *string* | - | | message | 展示文案 | *string* | - |
| duration | 持续时间 | *number* | `3000` | | duration | 持续时间 | *number* | `3000` |
| selector | 自定义选择器 | *string* | `van-notify` | | selector | 自定义选择器 | *string* | `van-notify` |
| color | 字体颜色 | *string* | `#fff` | | | color | 字体颜色 | *string* | `#fff` | |
| backgroundColor | 背景色 | *string* | `#f44` | | background | 背景色 | *string* | `#f44` |
| context | 选择器的选择范围,可以传入自定义组件的 this 作为上下文 | *object* | 当前页面 | | context | 选择器的选择范围,可以传入自定义组件的 this 作为上下文 | *object* | 当前页面 |
| safe-area-inset-top | 是否留出顶部安全距离(状态栏高度 + 导航栏高度) | *boolean* | `false` | | safe-area-inset-top | 是否留出顶部安全距离(状态栏高度 + 导航栏高度) | *boolean* | `false` |

View File

@ -6,12 +6,12 @@ VantComponent({
mixins: [safeArea()], mixins: [safeArea()],
props: { props: {
text: String, message: String,
color: { color: {
type: String, type: String,
value: '#fff' value: '#fff'
}, },
backgroundColor: { background: {
type: String, type: String,
value: RED value: RED
}, },

View File

@ -2,8 +2,8 @@
name="slide-down" name="slide-down"
show="{{ show }}" show="{{ show }}"
custom-class="van-notify" custom-class="van-notify"
custom-style="background-color:{{ backgroundColor }}; color: {{ color }}; z-index: {{ zIndex }};" custom-style="background:{{ background }}; color: {{ color }}; z-index: {{ zIndex }};"
> >
<view wx:if="{{ safeAreaInsetTop }}" class="van-notify__safe-top" style="padding-top: {{ statusBarHeight }}px"></view> <view wx:if="{{ safeAreaInsetTop }}" class="van-notify__safe-top" style="padding-top: {{ statusBarHeight }}px"></view>
{{ text }} {{ message }}
</van-transition> </van-transition>

View File

@ -1,14 +1,12 @@
import { isObj } from '../common/utils';
interface NotifyOptions { interface NotifyOptions {
text: string;
color?: string; color?: string;
backgroundColor?: string; zIndex?: number;
message: string;
context?: any;
duration?: number; duration?: number;
selector?: string; selector?: string;
context?: any; background?: string;
safeAreaInsetTop?: boolean; safeAreaInsetTop?: boolean;
zIndex?: number;
} }
const defaultOptions = { const defaultOptions = {
@ -16,8 +14,8 @@ const defaultOptions = {
duration: 3000 duration: 3000
}; };
function parseOptions(text: NotifyOptions | string): NotifyOptions { function parseOptions(message: NotifyOptions | string): NotifyOptions {
return isObj(text) ? (text as NotifyOptions) : ({ text } as NotifyOptions); return typeof message === 'string' ? { message } : message;
} }
function getContext() { function getContext() {