设置vue全局属性

如果vue项目共用的全局属性不多,可以不使用vuex,用this.$root去设置和取到全局属性

a.vue
this.$root.s = '设置了s属性'

b.vue
console.log(this.$root.s)  // 设置了s属性

你可能感兴趣的:(设置vue全局属性)