javascript - vue-class-component : Super expression must either be null or a function, 未定义

标签 javascript vue.js vue-class-components

好吧,这是一个奇怪的用例,但无论如何。

我有一个控件组件,它包括菜单组件,它还包括一个控件组件但没有菜单(奇怪的东西,但这就是设计)。

我做什么。

控制组件:

import {Component, Prop, Vue} from 'vue-property-decorator'
import Burger from "./Burger";
import ShadowLogo from "./ShadowLogo";
import MegaMenu from "./MegaMenu";

@Component
export default class Controls extends Vue {
  @Prop({default: false})
  showMenu: boolean;

  renderLogo(h) {
    return <div class="logo"><ShadowLogo/></div>
  }

  renderBurger(h) {
    return <Burger opened={this.showMenu} label="меню" on-want-change={e => this.$emit('show-menu', !this.showMenu)}></Burger>
  }

  renderFooter(h) {
    return <div class="copyrights"></div>
  }

  renderMenu(h) {
    return <div class="menu-layer">
      {this.showMenu ? <transition name="fade" appear={true}><MegaMenu/></transition> : null}
    </div>
  }

  render(h) {
    return <div class={["control-overlay", this.showMenu ? 'menu-opened' : null]}>
      {this.renderMenu(h)}
      {this.renderLogo(h)}
      {this.renderBurger(h)}
      {this.renderFooter(h)}
    </div>
  }
}

要插入菜单内部的菜单内部控件组件 — 相同,但没有菜单组件(显然是为了防止递归)

import Controls from "./Controls";
import {Component} from 'vue-property-decorator'

@Component
export default class MenuInnerControls extends Controls {
  renderMenu(h) {
    return null;
  }
}

但是在这个设置中我得到了一个错误:

51:13 Uncaught TypeError: Super expression must either be null or a function, not undefined
    at _inherits (51:13)
    at eval (51:19)
    at eval (MenuInnerControls.js?9737:8)
    at Object.<anonymous> (app.js:394)
    at __webpack_require__ (app.js:20)
    at eval (22:4)
    at Object.<anonymous> (app.js:219)
    at __webpack_require__ (app.js:20)
    at eval (18:8)
    at Object.<anonymous> (app.js:192)

(MenuInnerControls.js?9737:8 — 是继承类中的 renderMenu 方法)

最佳答案

好的,发现问题出在导入的循环依赖中。 Controls 呈现 MegaMenu,它呈现 MenuInnerControls 扩展 Controls。 即使如此,MenuInnerControls 也没有引用 MegaMenu,这会导致导入循环依赖。其他语言应该不是问题,但是js……哦

关于javascript - vue-class-component : Super expression must either be null or a function, 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49854020/

相关文章:

html - document.getElementById 在 Vue2 组件中未定义...因为误用了 watch?

javascript - 在已安装的 VueJS 中访问数据

typescript - 为什么 getter/setter 在 vue typescript 类组件中无法正常工作

typescript - vue 类组件 : how to create and initialize reflective data

javascript - 尝试从数组中选择一个随机索引 - 总是给我数组的最后一个索引

javascript - 如何将值传递给 Bootstrap Modal 的 href 链接?

javascript - 使用 v-on :change to pass specific object element to a function using Vue and Vuetify

typescript - 将数据传递给根 Vue 类组件

javascript - SVG鼠标事件在Firefox4中有效,但在IE8中无效

javascript - 光标位于文本框末尾时自动对焦