Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提取userToken.value #2

Closed
joostshao opened this issue May 8, 2024 · 1 comment
Closed

提取userToken.value #2

joostshao opened this issue May 8, 2024 · 1 comment

Comments

@joostshao
Copy link

joostshao commented May 8, 2024

// 获取userToken的JSON字符串
var userTokenString = localStorage.getItem('userToken');

// 如果userToken存在,则解析它
if (userTokenString) {
    try {
        // 解析JSON字符串为JavaScript对象
        var userToken = JSON.parse(userTokenString);
        
        // 假设我们要提取的键是'value'
        var keyValue = userToken.value;
        
        // 打印键的值
        console.log(keyValue);
    } catch (error) {
        console.error('Error parsing userToken JSON:', error);
    }
} else {
    console.log('userToken not found');
}
@Vinlic
Copy link
Member

Vinlic commented May 8, 2024

大家可以在F12 Console中粘贴这段代码直接获取。

@Vinlic Vinlic closed this as completed May 8, 2024
@Vinlic Vinlic pinned this issue May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants