Skip to content

Commit

Permalink
Merge pull request #380 from Tencent/toast0814
Browse files Browse the repository at this point in the history
fix: toast新增toast节点extClass接口
  • Loading branch information
BearJ committed Aug 14, 2023
2 parents 32b3b0f + 7d7f35a commit 981f24a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ document.querySelector('#confirmBtn').addEventListener('click', function () {
document.querySelector('#toastBtn').addEventListener('click', function () {
weui.toast('操作成功', {
duration: 3000,
className: "bears"
className: "bears",
extClass: "x"
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/toast/toast.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="<%= className %>" role="alert">
<div class="weui-mask_transparent"></div>
<div class="weui-toast">
<div class="weui-toast <%= extClass %>">
<i class="weui-icon_toast weui-icon-success-no-circle"></i>
<p class="weui-toast__content"><%=content%></p>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ let _sington;
* @param {number=} [options.duration=3000] 多少毫秒后关闭toast
* @param {function=} options.callback 关闭后的回调
* @param {string=} options.className 自定义类名
* @param {string=} options.extClass 自定义toast节点类名
*
* @example
* weui.toast('操作成功', 3000);
* weui.toast('操作成功', {
* duration: 3000,
* className: 'custom-classname',
* extClass: 'toast-classname',
* callback: function(){ console.log('close') }
* });
*/
Expand All @@ -53,7 +55,8 @@ function toast(content = '', options = {}) {
content: content,
duration: 3000,
callback: $.noop,
className: ''
className: '',
extClass: ''
}, options);

const $toastWrap = $($.render(tpl, options));
Expand Down

0 comments on commit 981f24a

Please sign in to comment.