1、新建一个globalVariable.js文件
2、定义要全局的变量
const UserId = "";
vue全局变量赋初值赋新值globalVariable
原文:https://www.cnblogs.com/lsyy2017/p/11219854.html