2024年06月17日 建站教程
安装脚手架:
npm install crypto-js import JSEncrypt from 'jsencrypt'
具体参考代码如下:
import AES from 'crypto-js/aes' import enc from 'crypto-js/enc-utf8' let text = 'Hello World' let key = 'secret-key' let encryptedText = AES.encrypt(text, key).toString() import JSEncrypt from 'jsencrypt' let text = 'Hello World' let publicKey = 'public-key' let encrypt = new JSEncrypt() encrypt.setPublicKey(publicKey) let encryptedText = encrypt.encrypt(text) axios.defaults.baseURL = 'https://api.example.com' axios.interceptors.request.use(function (config) { const token = localStorage.getItem('token') if (token) { config.headers.Authorization = 'Bearer ' + token } return config }, function (error) { return Promise.reject(error) })
本文链接:http://so.lmcjl.com/news/6749/