Auth0-lock 文档提供了一个将侦听器附加到身份验证状态更改事件的示例:
https://auth0.com/docs/libraries/lock/v11#2-authenticating-and-getting-user-info
// Listening for the authenticated event
lock.on("authenticated", function(authResult) {
// Use the token in authResult to getUserInfo() and save it to localStorage
lock.getUserInfo(authResult.accessToken, function(error, profile) {
if (error) {
// Handle error
return;
}
document.getElementById('nick').textContent = profile.nickname;
localStorage.setItem('accessToken', authResult.accessToken);
localStorage.setItem('profile', JSON.stringify(profile));
});
});
Auth0 Lock v11 的 API 参考提供了有关 支持的事件类型的更多详细信息on
,但没有关于删除侦听器的主题:
https://auth0.com/docs/libraries/lock/v11/api#on-
如何删除根据上面的示例设置的侦听器?