easyUI之Messager提示框的用法

素颜马尾好姑娘i 2022-08-24 00:49 1110阅读 0赞

分类

警告消息框(icon):alert error info question warning

交互消息框:confirm prompt

消息框的显示方式:show slide fade progress

警告消息框

基本用法:$.messager.alert(title, msg, icon, fn)

alert(普通提示)

  1. $(function () {
  2. $.messager.alert("操作提示", "操作成功!","alert");
  3. });

或不带“alert”

  1. $(function () {
  2. $.messager.alert("操作提示", "操作成功!");
  3. });

SouthEast

error(错误)

  1. $(function () {
  2. $.messager.alert("操作提示", "操作失败!","error");
  3. });

SouthEast 1

info(信息)

  1. $(function () {
  2. $.messager.alert("操作提示", "操作成功!","info");
  3. });

SouthEast 2

question(疑问)

  1. $(function () {
  2. $.messager.alert("操作提示", "您确定要执行此操作吗!","question");
  3. });

SouthEast 3

warning(警告)

  1. $(function () {
  2. $.messager.alert("操作提示", "该操作存在风险,请慎重!","warning");
  3. });

SouthEast 4

function的用法

  1. $(function () {
  2. $.messager.alert("操作提示", "该操作存在风险,请慎重!","warning",function(){
  3. alert("确定!")
  4. });
  5. });

交互消息框

基本用法:$.messager.confirm(title, msg, fn)

confirm(确认提示框)

  1. $.messager.confirm('提示', '请判断是否要执行该操作?', function(b){
  2. if (b){
  3. alert('确认');
  4. }else{
  5. alert('取消');
  6. }
  7. });

SouthEast 5

prompt(可输入信息的提示框)

  1. $.messager.prompt('提示', '请输入您要输入的内容:', function(r){
  2. if (r){
  3. alert('内容: '+r);
  4. }
  5. });

SouthEast 6

消息框的显示方式

具体显示效果自行实验,具体code如下:

  1. //显示
  2. $.messager.show({
  3. title:'提示',
  4. msg:'信息提示框将在4秒后关闭.',
  5. showType:'show'
  6. });
  7. //从下往上滑出
  8. $.messager.show({
  9. title:'提示',
  10. msg:'信息提示框将在5秒后关闭.',
  11. timeout:5000,
  12. showType:'slide'
  13. });
  14. //不主动关闭
  15. $.messager.show({
  16. title:'提示',
  17. msg:'信息提示框不会主动关闭.',
  18. timeout:0,
  19. showType:'fade'
  20. });
  21. //带滚动条等待提示框
  22. var win = $.messager.progress({
  23. title:'请等待',
  24. msg:'加载数据中...'
  25. });
  26. setTimeout(function(){
  27. $.messager.progress('close');
  28. },5000)

弹出框的位置

  1. function topLeft(){//上左
  2. $.messager.show({
  3. title:'My Title',
  4. msg:'The message content',
  5. showType:'show',
  6. style:{
  7. right:'',
  8. left:0,
  9. top:document.body.scrollTop+document.documentElement.scrollTop,
  10. bottom:''
  11. }
  12. });
  13. }
  14. function topCenter(){//上中
  15. $.messager.show({
  16. title:'My Title',
  17. msg:'The message content',
  18. showType:'slide',
  19. style:{
  20. right:'',
  21. top:document.body.scrollTop+document.documentElement.scrollTop,
  22. bottom:''
  23. }
  24. });
  25. }
  26. function topRight(){//上右
  27. $.messager.show({
  28. title:'My Title',
  29. msg:'The message content',
  30. showType:'show',
  31. style:{
  32. left:'',
  33. right:0,
  34. top:document.body.scrollTop+document.documentElement.scrollTop,
  35. bottom:''
  36. }
  37. });
  38. }
  39. function centerLeft(){//中左
  40. $.messager.show({
  41. title:'My Title',
  42. msg:'The message content',
  43. showType:'fade',
  44. style:{
  45. left:0,
  46. right:'',
  47. bottom:''
  48. }
  49. });
  50. }
  51. function center(){//中间
  52. $.messager.show({
  53. title:'My Title',
  54. msg:'The message content',
  55. showType:'fade',
  56. style:{
  57. right:'',
  58. bottom:''
  59. }
  60. });
  61. }
  62. function centerRight(){//中右
  63. $.messager.show({
  64. title:'My Title',
  65. msg:'The message content',
  66. showType:'fade',
  67. style:{
  68. left:'',
  69. right:0,
  70. bottom:''
  71. }
  72. });
  73. }
  74. function bottomLeft(){//下左
  75. $.messager.show({
  76. title:'My Title',
  77. msg:'The message content',
  78. showType:'show',
  79. style:{
  80. left:0,
  81. right:'',
  82. top:'',
  83. bottom:-document.body.scrollTop-document.documentElement.scrollTop
  84. }
  85. });
  86. }
  87. function bottomCenter(){//下中
  88. $.messager.show({
  89. title:'My Title',
  90. msg:'The message content',
  91. showType:'slide',
  92. style:{
  93. right:'',
  94. top:'',
  95. bottom:-document.body.scrollTop-document.documentElement.scrollTop
  96. }
  97. });
  98. }
  99. function bottomRight(){//下右
  100. $.messager.show({
  101. title:'My Title',
  102. msg:'The message content',
  103. showType:'show'
  104. });
  105. }

发表评论

表情:
评论列表 (有 0 条评论,1110人围观)

还没有评论,来说两句吧...

相关阅读