演示项目-图书馆
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.1 KiB

2 years ago
  1. <template>
  2. <div class="tishi-di" v-if="data.ifs">
  3. <div class="tishi">
  4. {{toastmassage}}
  5. </div>
  6. </div>
  7. </template>
  8. <script>
  9. import { reactive,computed,onMounted,watch } from 'vue';
  10. export default {
  11. props: {
  12. toastmassage: {
  13. type: String,
  14. default: ''
  15. },
  16. iftshow: {
  17. type: Number,
  18. default: 0
  19. }
  20. },
  21. setup(props){
  22. const data = reactive({
  23. timer:null,
  24. ifs:false
  25. })
  26. watch(() => props.iftshow, (oldVlaue, newValue) => {
  27. data.ifs = true;
  28. })
  29. watch(() => data.ifs, (oldVlaue, newValue) => {
  30. let that = data;
  31. clearTimeout(that.timer);
  32. that.timer = null;
  33. that.timer=setTimeout(function(){
  34. that.ifs = false;
  35. },1500)
  36. })
  37. return {
  38. data
  39. }
  40. }
  41. }
  42. </script>
  43. <style>
  44. .tishi-di{
  45. width: 100%;
  46. position: fixed;
  47. bottom: 16%;
  48. left: 0;
  49. display: flex;
  50. justify-content: center;
  51. align-items: center;
  52. }
  53. .tishi{
  54. padding: 0.18rem 0.40rem;
  55. background-color: rgb(226,226,226,0.9);
  56. font-size: 0.28rem;
  57. color: #222222;
  58. border-radius: 0.04rem;
  59. }
  60. </style>