Vue 2.0如何使用typescript中另一个文件的组件

时间:2018-01-05 18:01:10

标签: typescript webpack vuejs2 vue-component

我有一个文件,我有一个像这样注册的组件(/tables/mytable.ts):

import Vue from "vue";

Vue.component('my-table', {
  template: "<p>mycomponent</p>"
});

我想要使用我的组件(myvue.ts)的第二个文件:

import Vue from "vue";

// these two ways bellow don't working too
//import myTable from 'my-table'
//import { MyComponent } from '/tables/mytable.ts';

let v = new Vue({
  el: "#tabForUsers",
  template: "<my-table></my-table>"
});

我收到错误:

Unknown custom element: <my-table> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

在webpack中我分别拥有每个ts文件。

0 个答案:

没有答案