创建了一个全局函数文件:
module.exports = {
methods: {
t(key, replace = {}) {
return 'test';
}
}
}
然后导入到app with:
.mixin(require('./base'))
这个方法是有效的,但在我的IDE (PhpStorm)显示错误Unresolved function or method t
在Vue文件。如何为这样的函数显示提示?
需要用作named
或default
的导出
export const myMixin = {
methods: {
t(key, replace = {}) {
return 'test';
}
}
}
然后像
一样导入import Vue from 'vue';
import { myMixin } from '..../myMixin.js';
Vue.mixin(myMixin);