Vue 配置打包后可编辑的变量
- 在
public
目录下创建配置文件(如config.json
)
js
// public/config.json
{
"API_URL": "https://api.example.com",
"APP_VERSION": "1.0.0"
}
- 在需要的地方使用
js
async function loadConfig() {
const response = await fetch('/config.json');
const config = await response.json();
console.log(config)
}