foreword
I found a problem in the base debugging today, and record it here.
I used window.localStorage.getItem("token")
a function to get the token here. There is no problem when debugging locally, but this error is reported in the base debugging.
The reason may be that localStorage cannot be used directly in uni-app.
solution
1. Installmp-storage
npm install mp-storage
2. InstalllocalStorage
npm install localStorage
3. Configure vue.config.js
module.exports = {
configureWebpack:{
plugins: [
new webpack.ProvidePlugin({
'localStorage': ['mp-storage','localStorage'],
'window.localStorage': ['mp-storage', 'localStorage']
})
]
}
}
Finished, check the effect, the error message disappeared.