Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toast支持更多图标 #385

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules/
*.log
/docs/_book/
uploader-server/uploads
.DS_Store
8 changes: 6 additions & 2 deletions docs/component/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ toast 一般用于操作成功时的提示场景
| content | <code>string</code> | | toast的文字 |
| options | <code>Object</code> &#124; <code>function</code> | | 配置项或回调 |
| [options.duration] | <code>number</code> | <code>3000</code> | 多少毫秒后关闭toast |
| [options.type] | <code>'success'</code> &#124; <code>'warning' </code> &#124; <code>'error' </code>&#124; <code>'none' </code> | <code>'success'</code> | 显示的图标 |
| [options.callback] | <code>function</code> | | 关闭后的回调 |
| [options.className] | <code>string</code> | | 自定义类名 |
| [options.className] | <code>string</code> | | 自定义根节点类名 |
| [options.extClass] | <code>string</code> | | 自定义内容节点类名 |

**Example**
```js
weui.toast('操作成功', 3000);
weui.toast('操作成功', {
duration: 3000,
className: 'custom-classname',
type: 'none'
className: 'root',
extClass: 'content',
callback: function(){ console.log('close') }
});
```
10 changes: 9 additions & 1 deletion src/toast/toast.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<div class="<%= className %>" role="alert">
<div class="weui-mask_transparent"></div>
<div class="weui-toast <%= extClass %>">
<i class="weui-icon_toast weui-icon-success-no-circle"></i>
<% if(type === 'success'){ %>
<i class="weui-icon_toast weui-icon-success-no-circle"></i>
<% } %>
<% if(type === 'warning'){ %>
<i class="weui-icon_toast weui-icon-success-no-circle weui-icon-warn"></i>
<% } %>
<% if(type === 'error'){ %>
<i class="weui-icon_toast weui-icon-success-no-circle weui-icon-cancel"></i>
<% } %>
<p class="weui-toast__content"><%=content%></p>
</div>
</div>
2 changes: 2 additions & 0 deletions src/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ let _sington;
* weui.toast('操作成功', 3000);
* weui.toast('操作成功', {
* duration: 3000,
* type: 'success' | 'warning' | 'error'| 'none'
* className: 'custom-classname',
* extClass: 'toast-classname',
* callback: function(){ console.log('close') }
Expand All @@ -54,6 +55,7 @@ function toast(content = '', options = {}) {
options = $.extend({
content: content,
duration: 3000,
type: 'success',
callback: $.noop,
className: '',
extClass: ''
Expand Down