【问题标题】:Property 'hide' does not exist on type on build构建类型上不存在属性“隐藏”
【发布时间】:2021-03-05 13:41:52
【问题描述】:

我是 quasar 框架的新手。

我创建了一个组件并使用了它的模态弹出窗口。我关注了this

对话框正在使用下面打开。

methods: {
  openStoreModal(store:Store) {
    this.$q.dialog({
      component: StoreComponent,
      parent: this,
      title: store.name,
      store: store,
    });
  }
}

自定义对话框组件的 HTML。

HTML

<template>
  <q-dialog
    ref="dialog"
    @hide="onDialogHide"
  >
    <q-card 
      class="q-dialog-plugin"
      style="width: 700px; max-width: 80vw;"
    >

在自定义对话框组件内部

methods: {
  show() {
    this.$refs.dialog.show();
  },
  hide() {
    this.$refs.dialog.hide();
  },
  onDialogHide() {
    this.$emit('hide');
  },
  onCloseClick() {
    this.hide();
  }
}

我在构建时遇到此错误。

我在这里错过了什么?

【问题讨论】:

    标签: vue.js quasar-framework quasar


    【解决方案1】:

    如果不查看更多代码很难判断,但错误是 TS2339,它是由 Typescript 编译器生成的。我认为问题不在于 quasar-framework。

    请检查您在此线程中提到的接口/类型:error TS2339: Property 'x' does not exist on type 'Y'

    【讨论】:

    • 仅限this.$refs.dialog.show() 的问题。我已将 ref 给q-dialog。我添加了给出 ref 的 html。运行应用程序时,模态对话框打开和关闭正常。但它在构建生成时产生了问题。
    • 是的,当您运行构建时,编译器会查看您的代码,在这种情况下,它无法找到元素类型上隐藏和显示的定义。如果您有指向您项目的链接,我可以拉取并在本地运行?
    猜你喜欢
    • 2018-10-04
    • 1970-01-01
    • 2017-12-02
    • 1970-01-01
    • 1970-01-01
    • 2021-01-09
    • 2021-07-10
    • 1970-01-01
    相关资源
    最近更新 更多