main.vue 954 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <section v-show="vValue" class="absolute popup-screen center"
  3. @click="trigger && changeValue"
  4. :class="{'center':center}"
  5. >
  6. <section @click.stop :class="['popup-content-'+contentAnimate]">
  7. <slot></slot>
  8. </section>
  9. </section>
  10. </template>
  11. <script lang="ts">
  12. import props from '../props';
  13. export default <LibMixins>{
  14. name: "popup",
  15. data(){
  16. return {
  17. vValue:false
  18. }
  19. },
  20. watch:{
  21. value:{
  22. handler:function (this:any) {
  23. this.changeValue(this.value);
  24. },
  25. immediate:true
  26. }
  27. },
  28. methods:{
  29. // 发生变更
  30. changeValue(value:boolean=false):any{
  31. if (this.vValue !== value) {
  32. this.vValue = value;
  33. this.$emit(value ? 'open' :'close');
  34. if (this.value !== value) {
  35. return this.$emit('update:value',value);
  36. }
  37. }
  38. }
  39. },
  40. props
  41. }
  42. </script>
  43. <style scoped lang="scss" src="../style.scss"></style>