我想知道是否可以在插件中访问上下文变量?除“过程”对象外,还有哪些其他变量/对象?不幸的是,我在nuxt side
上找不到清晰的描述,也找不到关于“ process”对象的参考。即plugins / helper.js
const myHelper = {
helpFunction(arg) {
if (process.server) {
...
}
return ...;
},
答案 0 :(得分:0)
您应按照docs中的说明,在插件中导出一个函数以使用context
:
export default (context, inject) => {
context.app.helpFunction= (arg) => {
if (process.server) {
...
}
return ...;
}
}
现在您可以在任何这样的组件中使用您的辅助函数:
this.$helpFunction(someArgs)...