popup.js 418 B

1234567891011121314151617181920212223242526
  1. export default {
  2. data() {
  3. return {
  4. }
  5. },
  6. created(){
  7. this.popup = this.getParent()
  8. },
  9. methods:{
  10. /**
  11. * 获取父元素实例
  12. */
  13. getParent(name = 'uniPopup') {
  14. let parent = this.$parent;
  15. let parentName = parent.$options.name;
  16. while (parentName !== name) {
  17. parent = parent.$parent;
  18. if (!parent) return false
  19. parentName = parent.$options.name;
  20. }
  21. return parent;
  22. },
  23. }
  24. }