Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

引入elementUi的部分 #14

Open
webtianjia opened this issue Nov 20, 2018 · 8 comments
Open

引入elementUi的部分 #14

webtianjia opened this issue Nov 20, 2018 · 8 comments

Comments

@webtianjia
Copy link

我在main.ts 引入了elementUi,使用时却找不到他的方法

@Debiancc
Copy link

same issue..

@Debiancc
Copy link

declare global {
  namespace JSX {
    interface Element extends VNode{
      // 'el-form': ElForm
    }
    interface ElementClass extends Vue {}
    interface IntrinsicElements{
      [elem: string]: any;
    }
  }
}

我尝试使用tsx来写Vue,ts静态检查找不到elementUI可以使用上面这种方式来声明

@webtianjia
Copy link
Author

import Vue, { VNode } from 'vue';

declare global {
  namespace JSX {
    // tslint:disable no-empty-interface
    interface Element extends VNode {}
    // tslint:disable no-empty-interface
    interface ElementClass extends Vue {}
    interface IntrinsicElements {
      [elem: string]: any;
    }
  }
}

在src 目录下 shims-tsx.d.ts 但是它并没有生效

@webtianjia
Copy link
Author

56:14 Property '$Message' does not exist on type 'HelloWorld'.
    54 |
    55 |         public greet(i: any) {
  > 56 |             this.$Message("hello")
       |              ^
    57 |         }
    58 |     }
    59 |```

@ws456999
Copy link
Owner

@webtianjia 请问有最小重现的repo么

@ws456999
Copy link
Owner

@Debiancc @webtianjia

declare module 'vue/types/vue' {
  interface Vue {
    $Message: any,
    $Modal: any
  }
}

这段代码加到d.ts里面了么

@webtianjia
Copy link
Author

@Debiancc 已经可以了 ,我安装了 "vue-cli-plugin-element": "^1.0.0", 我使用了vue-cli3

@Debiancc
Copy link

@ws456999 这种workaround只是骗过tsc的静态检查,有什么办法可以让element-ui的types直接委托过来吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants