📜  将 Laravel .env 变量添加到 Vue 组件 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:12.251000             🧑  作者: Mango

代码示例1
in windows :

thats worked for me without any require in webpack.mix

... just add a new variable in env file with this prefix : MIX_

MIX_API_URL=http://laravel:8000
but need to restart php artisan serve and also restart npm run watch....

  let api_url = process.env.MIX_API_URL;
  console.log("my env variable:");
  console.log(api_url);