Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.8k views
in Technique[技术] by (71.8m points)

vue有没有像微信小程序那样可修改的全局变量

vue有没有像微信小程序那样可修改的全局变量

我想在vue中使用一个全局变量来存储数据,在全局都可以使用的,也可以修改,就类似微信小程序的那样。

1、我用过Vue.prototype.$http这个,但是这个不可以在其他页面修改

2、也用过store,这个在A页面修改完数据,跳转到B页面后,在created中可以获取,但是在B页面刷新一下,created就显示store里面的数据为空了

3、也试过了这种

export default {
    examId: '',
    setExamId(id) {
        this.examId = id;
    }
}

但是这样也遇到了和2中一样的情况

没有哪位大佬知道可以实现的方法?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

怎么不使用localStorage呢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...