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>
主要.ts
import SampleButton from './components/SampleButton.vue';
export {
  SampleButton,
};
export default {
  install(Vue: any, _options: object = {}): void {
    Vue.component(SampleButton.name, SampleButton);
  },
};
shims-vue.d.ts
declare module '*.vue' {
  import Vue from 'vue';
  export default Vue;
}
插件构建成功,但是当我尝试在我的应用程序中使用该插件时,出现错误:
import MyPlugin from 'my-plugin'
Vue.use(MyPlugin)
请帮我找出错误:)
| 归档时间: | 
 | 
| 查看次数: | 333 次 | 
| 最近记录: |