graceNvueHeaderAlert.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <view class="grace-alert" v-if="showIn">
  3. <view class="grace-alert-body" :style="{'background-color':background}" ref="gracealert">
  4. <slot></slot>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. var animation = weex.requireModule('animation');
  10. export default {
  11. name: "graceHeaderAlert",
  12. props: {
  13. show : {
  14. type : Boolean,
  15. default : false
  16. },
  17. background : {
  18. type : String,
  19. default : '#F1F2F3'
  20. }
  21. },
  22. data() {
  23. return {
  24. showIn : false
  25. }
  26. },
  27. watch: {
  28. show : function(n , o){
  29. this.showIn = true;
  30. setTimeout(() => {
  31. animation.transition(this.$refs.gracealert, {
  32. styles : {opacity:1},
  33. duration : 50,
  34. timingFunction : 'linear',
  35. needLayout : false,
  36. delay : 0
  37. });
  38. }, 100);
  39. setTimeout(function(){this.showIn = false;}.bind(this), 3000);
  40. }
  41. }
  42. }
  43. </script>
  44. <style scoped>
  45. .grace-alert{width:750rpx; flex-direction:row; flex-wrap:nowrap; justify-content:center; align-items:center; position:fixed; left:0rpx; top:20rpx;}
  46. .grace-alert-body{width:600rpx; padding:20rpx 25rpx; border-radius:10rpx; background-color:#FFFFFF; flex-direction:row; flex-wrap:nowrap; justify-content:center; align-items:center; opacity:0.1;}
  47. </style>