带 Typescript 的 Vue 插件 - 无法读取 null 的属性“_init”

Sim*_*mon 5 javascript typescript vue.js vuejs2

我需要创建包含一些可重用组件的 Vue 插件。我想使用 TypeScript 创建它。有我的文件:


组件/SampleButton.vue

<template>
  <button>Sample button</button>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
  name: 'sample-button',
});
</script>
Run Code Online (Sandbox Code Playgroud)

主要.ts

import SampleButton from './components/SampleButton.vue';

export {
  SampleButton,
};

export default {
  install(Vue: any, _options: object = {}): void {
    Vue.component(SampleButton.name, SampleButton);
  },
};

Run Code Online (Sandbox Code Playgroud)

shims-vue.d.ts

declare module '*.vue' {
  import Vue from 'vue';

  export default Vue;
}

Run Code Online (Sandbox Code Playgroud)

插件构建成功,但是当我尝试在我的应用程序中使用该插件时,出现错误:

import MyPlugin from 'my-plugin'

Vue.use(MyPlugin)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

请帮我找出错误:)