Vue在模板中混合了未解析的函数或方法



创建了一个全局函数文件:

module.exports = {
methods: {
t(key, replace = {}) {
return 'test';
}
}
}

然后导入到app with:

.mixin(require('./base'))

这个方法是有效的,但在我的IDE (PhpStorm)显示错误Unresolved function or method t在Vue文件。如何为这样的函数显示提示?

需要用作nameddefault的导出

export const myMixin = {
methods: {
t(key, replace = {}) {
return 'test';
}
}
}

然后像

一样导入
import Vue from 'vue';
import { myMixin } from '..../myMixin.js';
Vue.mixin(myMixin);

最新更新