小编Abh*_*mar的帖子

与元素 id 相同的字符串返回元素

我遇到了一种有效的情况,但我不明白为什么。如果我命名一个元素id="abc"并且不console.log(abc)先设置它,它就会给我 HTML 对象。任何人都可以解释这种行为吗?

例子

<h1 Id="abc" >abcdefghj</h1> 

<script>
  // without using document.getElementById
  console.log(abc); // Returns h1 element  
 </script>
Run Code Online (Sandbox Code Playgroud)

我不知道为什么它在不使用 document.getElementById() 的情况下给了我整个元素。

html javascript

29
推荐指数
1
解决办法
660
查看次数

Json Serializable - 无效参数(输入):不能为空

我正在尝试在我的模型类中设置 JSON 值。但其返回错误为无效参数(输入):不能为空

用户帐户.dart

import 'package:json_annotation/json_annotation.dart';
part 'userAccount.g.dart';


@JsonSerializable(nullable: true,disallowUnrecognizedKeys:true,includeIfNull:true)
class UserAccount{
     String id;
     String name;
     String email;
     String profile_pic;
     String country;
     String phoneNumber;
     bool isNewUser;
     int role;
     int account_status;
     String token;
     DateTime token_expiry;
     String facebook_profile_url;
     String google_profile_url;
     String twitter_profile_url;
     int matchStixx_count;
     DateTime created_at;
     DateTime updated_at;


     UserAccount({
          this.id,
          this.name,
          this.email,
          this.profile_pic,
          this.country,
          this.phoneNumber,
          this.isNewUser,
          this.role,
          this.account_status,
          this.token,
          this.token_expiry,
          this.facebook_profile_url,
          this.google_profile_url,
          this.twitter_profile_url,
          this.matchStixx_count,
          this.created_at,
         this.updated_at
     });

     factory UserAccount.fromJson(Map<String,dynamic> json) => _$UserAccountFromJson(json);

     Map<String,dynamic> toJson() =>_$UserAccountToJson(this);

}

Run Code Online (Sandbox Code Playgroud)

UserAccount.g.dart

part of 'userAccount.dart';

UserAccount …
Run Code Online (Sandbox Code Playgroud)

json jsonserializer dart nsjsonserialization flutter

0
推荐指数
1
解决办法
4036
查看次数