我从Vue移植时出错.从js到Nuxt.js.
我试着用node_modules
中的vue-session
.它编译成功,但在浏览器中我看到了错误:
未定义ReferenceError窗口
node_modules\vue-session\index.js
:
VueSession.install = function(Vue, options) {
if (options && 'persist' in options && options.persist) STORAGE = window.localStorage;
else STORAGE = window.sessionStorage;
Vue.prototype.$session = {
flash: {
parent: function() {
return Vue.prototype.$session;
},
所以,我遵循了this documentation:
rewardadd.vue
:
import VueSession from 'vue-session';
Vue.use(VueSession);
if (process.client) {
require('vue-session');
}
nuxt.config.js
:
build: {
vendor: ['vue-session'],
但我仍然无法解决这个问题.