【发布时间】:2020-01-22 21:18:35
【问题描述】:
我刚刚在我的项目中安装了 @nuxtjs/auth。
我得到Property '$auth' does not exist on type 'AuthLoginPage' 类。
登录类页面方法登录
this.$auth.loginWith('local', {
data: {
username: 'your_username',
password: 'your_password'
}
});
我的 nuxt.config.ts
modules: [
// Doc: https://axios.nuxtjs.org/usage
'@nuxtjs/axios',
'@nuxtjs/auth',
'@nuxtjs/pwa',
],
...
auth: {
strategies: {
local: {
endpoints: {
login: {
url: 'http://127.0.0.1:3001/users/login',
method: 'post',
propertyName: 'token'
},
logout: {
url: 'http://127.0.0.1:3001/users/logout',
method: 'post'
},
user: {
url: 'http://127.0.0.1:3001/users/me',
method: 'get',
propertyName: 'user'
}
},
// tokenRequired: true,
// tokenType: 'bearer'
}
}
我无法使用 NuxtJS Auth。
请问你有什么想法吗?
【问题讨论】:
-
你把它添加到 nuxt 配置了吗?如果是 - 显示你的配置
-
@Aldarund 是的,我添加了 nuxt.config.ts auth 配置插件。
-
您是否将其添加到 nuxt 配置的模块部分,您只显示了您的 nuxt 配置的一部分...?你在哪里称呼它?用什么方法?
-
@Aldarund 抱歉,我忘了完全添加配置 :) 我更新了第一条消息。你有什么想法吗?
-
在codesandbox上创建一个repro,没有它很难说
标签: typescript nuxt.js