【发布时间】:2019-09-01 15:09:52
【问题描述】:
我现在正在使用 nuxt.js。 但是在ie11中出现了一些错误。
首先我使用的是 vuetify 和 nuxt.js SSR(pwa) 模式。
IE11出现如下错误。
这是我的错误 https://i.imgur.com/mpkuXyN.png
我使用以下模块。
import Cookies from 'universal-cookie'
import CookieParser from 'cookieparser'
还有我的一些代码 我是新手开发者,代码可能很奇怪。
auth middleware
export default function ({ store, redirect, error }) {
if (!store.state.auth || store.state.error) {
return redirect('/login')
}
}
login.vue [The part that uses cookies]
methods: {
async Login (email, password) {
await this.$store.dispatch('obtainToken', { email: email, password: password })
.then((response) => {
// login success
let cookies = new Cookies()
let jwt = cookies.get('jwt')
if (jwt) {
this.$router.push(this.$route.query.redirect || '/')
} else {
this.login_false = true
}
})
}
}
index.vue [The part that uses cookies]
async asyncData ({ req, store, params, context }, callback) {
let cookies = new Cookies()
let jwt = cookies.get('jwt')
if (jwt) {
let [mainData] = await Promise.all([
axios.get('/api/profile/view', { headers: { Authorization: `Bearer ${jwt}` } })
])
store.dispatch('setuserData', mainData.data)
callback(null, { data: mainData.data })
} else {
let cookies = CookieParser.parse(req.headers.cookie)
let jwt = cookies.jwt
let [mainData] = await Promise.all([
axios.get('/api/profile/view', { headers: { Authorization: `Bearer ${jwt}` } })
])
store.dispatch('setuserData', mainData.data)
callback(null, { data: mainData.data })
}
},
nuxt.config.js
build: {
analyze: {
analyzerMode: 'static'
},
plugins: [
new webpack.ProvidePlugin({
'$': 'jquery',
jQuery: 'jquery'
})
],
extractCSS: true,
watch:['api'],
vendor:['babel-polyfill', '@johmun/vue-tags-input'],
extend (config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient && process.env.NODE_ENV !== 'production') {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/,
options: {
fix: true
}
})
}
if (ctx.isServer) {
config.externals = [
nodeExternals({
whitelist: [/^vuetify/]
})
]
}
}
},
我的代码有什么问题?还是这是一个模块问题? 请帮帮我!
【问题讨论】:
标签: internet-explorer cookies nuxt.js