Tiptoast.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <portal to="notification-outlet">
  3. <div class="toast-wrap" v-if="show">
  4. <div class="content">
  5. <p class="tit" v-show="data.title">{{data.title}}</p>
  6. <div class="text">
  7. {{data.text}}
  8. </div>
  9. <img src="../images/icon_close@2x.png" class="close" @click="handleClose">
  10. </div>
  11. <div class="mask" @click="handleClose"></div>
  12. </div>
  13. </portal>
  14. </template>
  15. <script type="text/javascript">
  16. /**
  17. 提示性弹窗组件
  18. 接收参数:
  19. show-布尔值,是否显示弹窗;
  20. data-对象,包含title和text;
  21. @close-关闭弹窗的方法(点击关闭按钮或者遮罩都关闭弹窗)
  22. **/
  23. export default {
  24. name:'Tiptoast',
  25. data(){
  26. return {
  27. msg:""
  28. }
  29. },
  30. props:{
  31. show:{
  32. default:false,
  33. type:Boolean
  34. },
  35. data:{
  36. default:{
  37. title:'',
  38. text:''
  39. },
  40. type:Object
  41. },
  42. },
  43. methods:{
  44. handleClose(){
  45. this.$emit("close")
  46. },
  47. },
  48. }
  49. </script>
  50. <style lang="less" scoped>
  51. @import '../less/base.less';
  52. .toast-wrap{
  53. .content{
  54. width: 6rem;
  55. background: #fff;
  56. z-index: 999;
  57. position: fixed;
  58. top:50%;
  59. left: 50%;
  60. transform: translate(-50%,-50%);
  61. padding: .5rem .8rem .8rem;
  62. box-sizing: border-box;
  63. border-radius: .20rem;
  64. z-index: 1000;
  65. .tit{
  66. font-family:PingFangSC;
  67. color:#333333;
  68. font-size: .32rem;
  69. text-align: center;
  70. font-weight: 700;
  71. }
  72. .text{
  73. color:#colors[quest];
  74. padding-top: .3rem;
  75. font-size: .3rem;
  76. }
  77. .close{
  78. width:1rem;
  79. position: absolute;
  80. bottom: -1.5rem;
  81. left: 50%;
  82. margin-left: -.5rem;
  83. }
  84. }
  85. .mask{
  86. .mask;
  87. z-index: 999;
  88. }
  89. }
  90. </style>