- 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 了。就是这么喜新厌旧。
If the field names in your Model class are not exactly the same as in a JSON string, you will need adding an option to guarantee the behavior is what you want. For example, if you have got the following response text:
{"hello":"world"}
and you have a Model class below:
class SampleModel
{
public string Hello { get; set; };
}
You can see the property name in your Model class is "Hello" instead of "hello", the following code won't get an expecting result.
SampleModel s = JsonSerializer.Deserialize<SampleModel>("{\"hello\":\"world\"}");
you will get an object like
{
"Hello": null
}
You have to use an option below to get it to work.
SampleModel s = JsonSerializer.Deserialize<SampleModel>("{\"hello\":\"world\"}", new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
});
on the other hand, you have to use the following code to guarantee the serialize behavior:
SampleModel s = JsonSerializer.Serialize(new SampleModel() {Hello="world"}, new JsonSerializerOptions
{
DictionaryKeyPolicy = JsonNamingPolicy.CamelCase
});
Thus you get {"Hello":"world"}
instead of {"hello":"world"}
.
System.text.json sucks.