严格来说,二者是两个维度,并没有必然的固定的映射关系。只是通常情况下,约定俗成的:
--mode test <=> NODE_ENV=test
--mode development <=> NODE_ENV=development
--mode production <=> NODE_ENV=production
--mode staging <=> NODE_ENV=staging
那怎么知道手头的项目是否符合这个约定俗成呢?通常来说,你可以看一下项目根目录下的 .env 系列文件,一般情况下,NODE_ENV 变量会定义在那里。
- Bound object changes but the UI didn't change. Solution:
Template part,
<el-select v-model="form.categoryIdList" multiple @change="setValue(form.categoryIdList)">
Component part,
setValue(object) {
this.$set(this.form, this.form.categoryIdList, object)
},
- VUE_APP_CUSTOM_VARIBLE doesn't work, solution:
Restart your dev server.
bash
ASPNETCORE_URLS="http://*:9143" ASPNETCORE_ENVIRONMENT="Development" dotnet Yourproject.dll
ASPNETCORE_ENVIRONMENT="Development" dotnet run --urls "http://*:9143" --no-launch-profile
for Windows command line (cmd.exe)
setx ASPNETCORE_URLS "http://localhost:5001"
setx ASPNETCORE_ENVIRONMENT "Development"
dotnet Yourproject.dll
for Windows powershell
$Env: ASPNETCORE_URLS "http://localhost:5001"
$Env: ASPNETCORE_ENVIRONMENT "Development"
dotnet Yourproject.dll
Reference
同事前两天遇到一个离奇的 axios 问题,response.data看上去非常正常,但无法访问这个对象里面的任何一个键。console.log(response.data)
一看果然是 string。
同事很茫然,一直都好好的,也没有改什么啊。
改了 db.json。里面有一个多余的逗号。axios解析json字符串失败,就一声没吭的返回了字符串而非对象。这个坑货!想想axios也很无辜....因为我们有时候可能真的会有需要返回字符串。所以写期望的返回数据时,别偷懒又允许json又允许text。也许只允许json就不会有这个问题了。(待验证)
Reference
这是我从新近follow的一个推友 @tywtywtyw 的推文里拣到的宝。他在推文里说
放弃了 postman 和 postwomen, 来到了 insomnia
能比 Postman 更好?这勾起了我的好奇心。结果发现真香。
顺便说一下,他的口号是“Design and debug APIs like a human, not a robot.”
- 不用写脚本,可以指定当前请求依赖哪个请求,以及是使用缓存的请求结果,还是需要时再发新请求(通常我都会选择发新请求,毕竟token会过期)
- 最重要的键是 Ctrl+空格。这是 autocomplete 的热键。
- 界面相对易用。
- 有父环境和子环境的概念,公共的东西写到父环境里,能省一些时间
- 就像使用苹果的软件,你不需要专门保存你的接口,你写了,你run了,接口就自动存好了。
遇到一个坑:如果是在JSON里使用环境变量,并且这个变量是个字符串,得用双引号括住这个变量!
我已经决定扔掉 Postman 了。就是这么喜新厌旧。