2017-03-31 49 views
0

我延长了默认的Vue对象与如何来增强Vue公司类并保持打字稿定义同步

export default (Vue) => { 
    Object.defineProperties(Vue.prototype, { 
    $http: { 
     get() { 
     return axiosInstance 
     } 
    } 
    }) 
} 

我使用打字稿当然打字稿的和不喜欢这一点。 如何以这种方式创建项目特定的.d.ts文件vue typescript声明是增加了上述扩展?

回答

3

创建具有以下内容的文件:

import {AxiosStatic} from 'axios'; 


declare module 'vue/types/vue' { 
    export interface Vue { 
    $http: AxiosStatic; 
    } 
}