barriers / 阅读 / 详情

哪位能说说C#反射的GetCustomAttributes方法

2023-07-08 12:09:44
共3条回复
南yi
使用反射访问属性(C# 编程指南)
如果没有检索自定义属性的信息和对其进行操作的方法,则定义自定义属性并将其放置在源代码中就没有意义。C# 具有一个反射系统,可用来检索用自定义属性定义的信息。主要方法是 GetCustomAttributes,它返回对象数组,这些对象在运行时等效于源代码属性。此方法具有多个重载版本。有关更多信息,请参见 Attribute。属性规范,如:C#
[Author("H. Ackerman", version = 1.1)]
class SampleClass在概念上等效于:C#
Author anonymousAuthorObject = new Author("H. Ackerman");
anonymousAuthorObject.version = 1.1;但是,直到查询 SampleClass 以获取属性时才会执行此代码。对 SampleClass 调用 GetCustomAttributes 会导致按上述方式构造并初始化一个 Author 对象。如果类还有其他属性,则其他属性对象的以类似方式构造。然后 GetCustomAttributes 返回 Author 对象和数组中的任何其他属性对象。之后就可以对此数组进行迭代,确定根据每个数组元素的类型所应用的属性,并从属性对象中提取信息。 示例下面是一个完整的示例。定义一个自定义属性,将其应用于若干实体并通过反射进行检索。C#
[System.AttributeUsage(System.AttributeTargets.Class |
System.AttributeTargets.Struct,
AllowMultiple = true) // multiuse attribute
]
public class Author : System.Attribute
{
string name;
public double version; public Author(string name)
{
this.name = name;
version = 1.0; // Default value
} public string GetName()
{
return name;
}
}[Author("H. Ackerman")]
private class FirstClass
{
// ...
}// No Author attribute
private class SecondClass
{
// ...
}[Author("H. Ackerman"), Author("M. Knott", version = 2.0)]
private class ThirdClass
{
// ...
}class TestAuthorAttribute
{
static void Main()
{
PrintAuthorInfo(typeof(FirstClass));
PrintAuthorInfo(typeof(SecondClass));
PrintAuthorInfo(typeof(ThirdClass));
} private static void PrintAuthorInfo(System.Type t)
{
System.Console.WriteLine("Author information for {0}", t);
System.Attribute[] attrs = System.Attribute.GetCustomAttributes(t); // reflection foreach (System.Attribute attr in attrs)
{
if (attr is Author)
{
Author a = (Author)attr;
System.Console.WriteLine(" {0}, version {1:f}", a.GetName(), a.version);
}
}
}
}
输出Author information for FirstClassH. Ackerman, version 1.00Author information for SecondClassAuthor information for ThirdClassH. Ackerman, version 1.00M. Knott, version 2.00
再也不做稀饭了

使用反射访问属性(C# 编程指南)

如果没有检索自定义属性的信息和对其进行操作的方法,则定义自定义属性并将其放置在源代码中就没有意义。C# 具有一个反射系统,可用来检索用自定义属性定义的信息。主要方法是 GetCustomAttributes,它返回对象数组,这些对象在运行时等效于源代码属性。此方法具有多个重载版本。有关更多信息,请参见 Attribute。属性规范,如:C#

[Author("H. Ackerman", version = 1.1)]

class SampleClass在概念上等效于:C#

Author anonymousAuthorObject = new Author("H. Ackerman");

anonymousAuthorObject.version = 1.1;但是,直到查询 SampleClass 以获取属性时才会执行此代码。对 SampleClass 调用 GetCustomAttributes 会导致按上述方式构造并初始化一个 Author 对象。如果类还有其他属性,则其他属性对象的以类似方式构造。然后 GetCustomAttributes 返回 Author 对象和数组中的任何其他属性对象。之后就可以对此数组进行迭代,确定根据每个数组元素的类型所应用的属性,并从属性对象中提取信息。 示例下面是一个完整的示例。定义一个自定义属性,将其应用于若干实体并通过反射进行检索。C#

[System.AttributeUsage(System.AttributeTargets.Class |

System.AttributeTargets.Struct,

AllowMultiple = true) // multiuse attribute]public class Author : System.Attribute{string name;

public double version; public Author(string name){this.name = name;

version = 1.0; // Default value

} public string GetName(){return name;}}[Author("H. Ackerman")]

}// No Author attribute

}[Author("H. Ackerman"), Author("M. Knott", version = 2.0)]

}class TestAuthorAttribute{static void Main(){PrintAuthorInfo(typeof(FirstClass));

PrintAuthorInfo(typeof(SecondClass));

PrintAuthorInfo(typeof(ThirdClass));

LocCloud

首先,你是否了解.net的特性这个东西?如果你了解了,这个东西不难理解。

相关推荐

attributes是什么意思

attribute 英[u0259u02c8tru026abju:t] 美[u0259u02c8tru026abjut] vt. 认为…是; 把…归于; 把…品质归于某人; 认为某事[物]属于某人[物]; [网络] 属性; 特性; 性质; [例句]Don"t attribute all your mistakes to objective causes.不要把你的错误都归咎于客观原因。[其他] 第三人称单数:attributes 复数:attributes 现在分词:attributing过去式:attributed 过去分词:attributed 形近词: distribute contribute
2023-07-08 07:18:511

什么是Attribute

n.属性; 象征v.把…归因于; 认为…属于; 认为某人(某物)具有某种特性网络定语; 特征; 品质变形过去式:attributed; 现在分词:attributing; 第三人称单数:attributes搭配attribute blame例句The name of the element to be created is specified by a required name attribute and an optional namespace attribute.要创建的元素的名称由必选的name属性和可选的namespace属性指定。
2023-07-08 07:18:581

attribute是什么意思

attribute意思是归因于,归咎于等,详细含义介绍如下:1、基本释义:归因于,归咎于,认为是由于,认为是某人所做,认为是所为,认为属于,认为某人所有,认为是某人创造,认为某作品出自某人之手,认为是产生,把某品质归于某人,认为某人具有某品性。人或物的属性,特性,特征,品性,品质,标志,象征,表征。2、用法:语法修饰语,定语,属性形容词,限定词在名词短语中修饰名词的形容词,Any incomes policy must embody the attributes of fairness and flexibility.任何收入都应该具有公平与灵活性之特征。3、双语例句:Public perception can also create a legal right for an attribute of a product.公众的认知也能为产品的某个属性创造权利。The attribute that indicates that the same copy of a routine cannot be used by another task.一种属性,表示某一例行程序的同一副本不能被另一个任务使用。
2023-07-08 07:19:051

C#中的特性(Attribute)用途?

第一个问题,你可以参考我的另一个回答:http://zhidao.baidu.com/question/463506213.html。第二个问题,答案是可以。例子,我明天早上补充给你。
2023-07-08 07:19:573

attribute和property在英语里有什么区别

1)attribute翻译成中文术语为“特性”attribute是一个特性节点,每个DOM元素都有一个对应的attributes属性来存放所有的attribute节点,attributes是一个类数组的容器,说得准确点就是NameNodeMap,总之就是一个类似数组但又和数组不太一样的容器。attributes的每个数字索引以名值对(name=”value”)的形式存放了一个attribute节点。2)property翻译成中文术语为“属性”property就是一个属性,如果把DOM元素看成是一个普通的Object对象,那么property就是一个以名值对(name=”value”)的形式存放在Object中的属性。
2023-07-08 07:20:041

contribute和attribute区别

contribute和attribute指代不同,用法不同,侧重点不同。Attribute的意思是把…归因于;contribute的意思为是…的原因之一。attribute指人或物及其地位、属性的象征;contribute指选定象征一个国家、民族或家庭等的图案或实物。attribute用作动词的基本意思是“归因于”,指“把某事归因于某人〔某事〕”“认为某作品出自某人之手”“认为某事〔物〕属于某人〔物〕”,常用于attributesth to sb/sth 结构。 contribute可表示“捐赠,捐献”“促成,组成…的一部分”,还可作“贡献(意见、建议等)”解,有时可指“投稿”。作不及物动词,其后常加介词to。 This book contributes little to our understanding of the subject. 此书对我们了解这门学科助益甚少。 She contributed a number of articles to the magazine. 她给这家杂志撰写了一些稿件。 She attributes her success to hard work and a little luck. 她认为她的成功来自勤劳和一点运气。 The committee refused to attribute blame without further information. 如果没有进一步的情况,委员会拒绝归罪于任何人。
2023-07-08 07:20:221

Attribute 是VB中的什么属性

Attributes属性(远程数据)返回一个值,用以指示rdoColumn对象的一个或多个特性。语法object.Attributesobject所在处是一个对象表达式,其值是“应用于”列表中的一个对象。返回值Attributes属性的返回值,用以指定由rdoColumn对象表示的列的特性
2023-07-08 07:20:351

attribute与property

HTML 中的 node 有一个方法:cloneNode(),这个方法用来复制一个节点。不过它还有一个值得注意的地方。 WTF,attribute 和 property 不是同一个东西吗? 你看,设置了 property,获取 attribute 是同一个东西吧。 不过,它们确实不是能够等同而视的东西,事实上,它们之间的差别还挺大的。 在最为根本的地方(语义上)可以似乎可以揣摩出一些这两者的差异:attribute 写在标签上的,主要用来表示节点的特征的属性。 而 property 是从 dom 对象角度考虑。 另外,每一个 attribute(key + value) 本身也是一个节点 (attr node)。 它们是同等级别的东西 …… 每种类型的 tag 都有自己的默认预设的 attribute,像 img 标签的 src, script 标签的 async。 除此之外,我们还可以自定义一些 attribute 在 HTML 中,每一个 node,都有一个 attributes 属性,它的值是一个 NamedNodeMap ,存有当前 node 的所有 attributes。 NamedNodeMap 提供了一些操作 attribute 的方法: getNamedItem(name) : 获取 nodeName 为 name 的 node (这里的 node 就是指 attr node) item(pos) : 同上,不过这个还可以用来设置值 removeNamedItem(name) : 删除 setNamedItem(attrNode) : 存一个 node ,注意,依然是 attr node attributes 属性的主要用途是遍历一个 element 的 attributes 事实上,所有的默认的 attributes 也会作为 DOM 的 property,只不过,有一点需要注意,不同类型的tag,有自己专属的 attribute,只有专属的 attribute 才能够在 property 中直接获取。比如: 自定义的 attributes 也无法通过 property 获取,自然也无法通过 property 修改自定义的 attribute. 1.class, 获取时用到的关键字不一样,通过 attribute 的方式获取是 dom.getAttribute("class") ; 而通过 property 的方式获取是 dom.className 1.style : getAttribute 得到 CSS text ; dom.style 是一个对象; 2.onclick 之类的事件 : getAttribute 得到的是字符串 "fn()" ; dom.onclick 是 function 3.对于那些对于值有所限制 (比如 src, disabled, multiple)、或功能性(比如 value)的 attributes,这种限制或功能更多是体现在 property 上: attributes 与 property 很不一样 …… 那么,在深拷贝一个 dom 的时候,如何把某个数据也复制过去呢? 1.写在 dom 元素上 2.使用 setAttribute 参考文献: 1.《JavaScript高级程序设计》第三版 2. stackoverflow 上有个值得参考的理解
2023-07-08 07:20:421

js中Property和Attribute的区别是什么

总结为attribute节点都是在HTML代码中可见的,而property只是一个普通的名值对属性。attribute:attributes类似数组的容器,名字索引存放的是name=value的attribute的节点,要设置一个attribute节点使用setAttribute方法,要删除就用removeAttribute.attributes是会随着添加或删除attribute节点动态更新的.property就是一个属性很多attribute节点还有一个相对应的property属性,比如上面的div元素的id和class既是attribute,也有对应的property,不管使用哪种方法都可以访问和修改。
2023-07-08 07:20:492

请教Attributes属性的用法

Text1.Attributes["onfocus"] = "alert(Text1.value)";TextBox对应的客户端标签是<input type="text" ..../>,就是给这个html元素设置onfocus属性,属性值为alert(Text1.value)。Attributes["属性名"]可以理解为给控件对应的客户端标记设置相应html属性。
2023-07-08 07:20:561

Attribute和Property的区别

property是指类向外提供的数据区域。而attribute则是描述对象在编译时或运行时属性的,分为固有型和用户自定义型,其中用户自定义型可以利用Reflection在运行期获取。这两者是有本质区别的。资料上说二者一个是service的属性,而另一个是interface的。第一种好象更准确,摘要如下:在很多人的脑海中,Attribute就是类的属性,Property呢?好像也是类的属性?因此有很多人不加区别的统一称为类的属性,尤其是在写中文文章的时候。这种心理是典型的鸵鸟心态,眼不见为净。其实稍微用脚想一下就知道,事实肯定不是这样的,UML中既然发明了这两个术语,显然不是用来冗余的。它们之间肯定有着千丝万缕的联系与区别。各种各样的面向对象语言、各种组件技术、模板技术、Web Service技术,其中大部分涉及到了“属性”这个概念,而其英文术语则常常是Attribute、Property或者Field。很多人一概称之为“属性”,有的地方确实可以不加区分,但有的地方却是差之毫厘、谬以千里。我对于这些纷纷扰扰的技术和术语也很苦恼,但是我们至少可以通过UML中的这两个术语的解释找到一个可以参考的标准。无论如何,UML是面向对象技术的集大成者和事实上的标准。很客观的说,UML1.4中对于这两个术语并没有很清晰的定义,但是其区别还是显而易见的。Attribute应该是UML1.4中的宠儿,而Property连一个单独的术语都没有捞到。谁也没想到在UML2.0中风云突变,Attribute从类图中消失了,而Property堂而皇之入主中原。1。4中 Attribute是与Classifier相关联的术语,它比Property的影响范围要小。Class是Classifier的子类,因此Attribute也可以表示Class的属性。从上面的定义还可以看出,Attribute可以是Classifier的实例的命名的槽。对于Class来说,其实例就是Object,Object的槽就是对象的属性值槽。因此,Attribute是可以作为对象的属性的。而Property似乎没有这一层的含义。按MOF(元对象设施,OMG的另一个规范,后面会有详细解释)的模型层次划分,Attribute涉及的模型层从M2到M0,而Property似乎只是M2层的概念。2。0中 Attribute这里仅仅指一个类元的结构特征,可以将类元的实例联系到一个或者一组具体值。而没有提到实例的槽(slot)等等。我猜想,这是因为UML2.0中已经把Attribute作为Property的一个子集了,所以关于实例的槽(slot)等等的具体赋值方法,都归结到Property的定义中解释了。另外一点值得注意的是,Attribute的定义来自于术语表,而没有在元模型图中出现。而Property出现在元模型图中,并且都做了详细而具体的解释。这一点可以看出,UML强化Property,弱化Attribute的决心。Attribute和Property的总结这一节对Attribute和Property作一个小结,基于目前最新的UML2.0规范:l 总体上来说,Attribute是Property的子集,Property会在适当的时机表现为Attribute;l Property出现在类图的元模型中,代表了Class的所有结构化特征;Attribute没有出现在元模型中,它仅仅在Class的概念中存在,没有相应的语法了;l Property有详细的定义和约束,而Attribute没有详细的定义,因此也不能用OCL写出其约束。l Property和Attribute都是M2层的概念。在M1层,它们的实例是具体类的属性;在M0层,它们的实例的实例是具体对象的槽中存储的值。对于property和attribute这两个名词都叫“属性”的问题,来源于国内it书籍翻译界的疏忽。其实它们来源于两个不同的领域,attribute属于OOA/OOD的概念,而property属于编程语言中的概念。下面我们来说明它们的异同。AttributeAttributes是Microsoft .NET Framework文件的元数据,可以用来向运行时描述你的代码,或者在程序运行的时候影响应用程序的行为。Property属性是面向对象编程的基本概念,提供了对私有字段的访问封装,在C#中以get和set访问器方法实现对可读可写属性的操作,提供了安全和灵活的数据访问封装。关于属性的概念,不是本文的重点,而且相信大部分的技术人员应该对属性有清晰的概念。以下是简单的属性区别可以说两者没有可比性,只不过我们国家的语言特点才引起的歧异,其实只要记住Attribute是派生于System,Attribute类之下,它的主要作用是描述,比如某为了描述某个方法是来自与外部的dll,可以写如下代码,这就是一个Attribute,他是一个描述(或者说声明)[DllImport("User32.dll")]Attribute也有很多系统的“默认”属性,见下表预定义的属性有效目标说明AttributeUsageClass指定另一个属性类的有效使用方式CLSCompliant全部指出程序元素是否与CLS兼容ConditionalMethod指出如果没有定义相关联的字符串,编译器就可以忽略对这个方法的任何调用DllImportMethod指定包含外部方法的实现的DLL位置STAThreadMethod(Main)指出程序的默认线程模型为STAMTAThreadMethod(Main)指出程序的默认模型为多线程(MTA)Obsolete除了Assembly、Module、Parameter和Return将一个元素标示为不可用,通知用户此元素将被从未来的产品ParamArrayParameter允许单个参数被隐式地当作params(数组)参数对待SerializableClass、Struct、enum、delegate指定这种类型的所有公共和私有字段可以被串行化NonSerializedField应用于被标示为可串行化的类的字段,指出这些字段将不可被串行化StructLayoutClass、struct指定类或结构的数据布局的性质,比如Auto、Explicit或sequentialThreadStaticField(静态)实现线程局部存储(TLS)。不能跨多个线程共享给定的静态字段,每个线程拥有这个静态字段的副本而Property是指编程过程中的字段,也即类的成员。如:private int hour; //定义私有变量表示"小时",外部是访问不到的.} public int Hour// 定义Hour程序接口{set { hour=value; }get { return hour;}
2023-07-08 07:21:041

java 中 如何遍历Attributes中的信息

java中便利主要有迭代器Iterator 和foreach 你要遍历什么东西主要是看返回值,用什么存储。就ok了
2023-07-08 07:21:114

asp.net 中的Attributes 属性

很简单 属性就相当于人的特征比如控件的name就相当于人的名字 id就相当于你的省份证号码等等 然后别人就可以通过你的特征找到你控件也一样
2023-07-08 07:21:302

VB中Dir()函数的attributes参数不解。

返回具体该属性的文件名。
2023-07-08 07:21:376

如何使用DEL命令中的[/A[[:]attributes]]

del c:a*.txt /f /a:R那就是你的c盘根目录下没有a打头,后缀为txt的文件,另外,最好不要拿C盘根目录做实验,比较危险。-----------------------------attributes R 只读文件 S 系统文件 H 隐藏文件 A 存档文件 del d:a.txt /f /a:R最后的/a:R表示删除属性为R(Readonly)的文件,所以你要把a.txt文件改为只读属性,不信你可以自己试一下!
2023-07-08 07:21:511

看图理解:OpenGL 的三种变量类型(uniform、attributes、Textrue Data)

回顾: 1. 快速理解OpenGL专业名词 2. 看图解析:OpenGL“图元” OpenGL 被设计为客户端与服务端端CS模型。客户端为应用程序调用的OpenGL接口,运行在CPU上向服务端发送各种渲染请求。而服务端则会通过图形渲染管线执行真正的渲染工作。运行在GPU上。 在shader 中,属性变量和统一变量需要由应用设置,attribute属性变量用于传递顶点信息,而uniform统一变量则用于传递用户自定义的变量。这两种变量在shader中会被定义为全局变量。 1. uniform(统一变量) 2. attributes(属性) 3. Textures(纹理) 文献 OpenGL ES 3.0之Uniform详解 OpenGL Texture 纹理 精通Cocos2d-x游戏开发(进阶卷) 三 基础渲染-opengl基础渲染架构
2023-07-08 07:21:581

arcgis软件中"metadata"所描述的的description,spatial,attributes分别描述什么内容?

元数据的英文名称是“Metadata",它是“关于数据的数据”在地理空间信息中用于描述地理数据集的内容、质量、表示方式、空间参考、管理方式以及数据集的其他特征,它是实现地理空间信息共享的核心标准之一。description,spatial,attributes。分别表述描述、空间参考、数据集内容。
2023-07-08 07:22:052

计算机程序python语言里arguments,parameters,attributes区别是什么

arguments变元,实质是一个具体数值parameters参数,实质是一个变量名称attributes属性,实质是一个函数,实现某种功能
2023-07-08 07:22:121

(ARM + Linux)GNU链接脚本中的".ARM.attributes"是什么意思?

跟arm相关的信息
2023-07-08 07:22:212

narrowing-down attributes是什么意思

narrowing-down attributes 缩小属性narrowing-down attributes 缩小属性narrowing-down attributes 缩小属性
2023-07-08 07:22:291

getAttributes()方法参数问题

这个你要拿到DirContext这个类看看了,request.getAttributes没有这个参数,貌似缺省值。
2023-07-08 07:23:001

如何更改word的attributes

方法一:07版的Word打开后,选择左上角的office图标按钮——准备——属性,会出现作者、标题等信息,全部删掉后,保存Word即可方法二:07版的Word打开后,选择左上角的office图标按钮——准备——检查文档,勾选“文档属性和个人信息”——检查——“全部删除”,保存Word即可
2023-07-08 07:23:071

attribute to中文翻译

The play is attributed to shakespeare . 这剧本被认为是莎士比亚写的。 The randomness is attributed to the porous medium . 随机性起因于多孔介质。 It was immediately attributed to their sedentary pfe . 这一点立刻归咎于他们终日伏案的生活。 Such a dichotomy cannot simply be attributed to coincidence . 这样一种分歧不能简单归之于巧合。 It is preposterous to attribute to mere external conditions . 仅仅以外部环境解释一切是不合理的。 Another meaning can be attributed to the function u(x, t) . 还可以赋于函数U(x,t)以另一种意义。 Boll rot has been attributed to a wide range of organi *** s . 棉铃腐烂是由分布范围广泛的微生物引起的。 Relative deprivation is attributed to inequapties in the social system . 相对剥夺来自社会制度的不平等。 All this she attributed to the prejudice and conceit of the archdeacon . 她把这一切全归咎于会吏长的偏见与自高自大。 Orifice"s pressure losses are attributed to entrainment and eddy formation . 孔板的压力被认为是由卷吸和涡流造成的。 That is mistakenly attributed to a nonexistent mysterious disease . 被误认为是实际上并不存在的所谓神密疾病所造成的。 The same subpme authority is attributed to the new prohibition as to the old . 新禁律和旧禁律一样都有至高无上的权威。 Many of these adulatory characterizations were attributed to unnamed sources . 在这些献媚取宠的特写当中,很多材料来源不清。 Claims made for spontaneous generation are now attributed to an innocent form of self-deception . 现在认为元生源论的发表是来自天真的自欺。 The invention of percussion positions for igniting powders is usually attributed to forsyth . 通常认为用以引燃的击发药是弗尔赛思发明的。 The remaining portion of heat losses of the earth are mostly attributed to the coopng of the earth . 地球热损耗的其余部分主要来自地球的冷却作用。 Such stoppages as are observed in practice are thus attributed to mistakes or even irrationapty . 在实际情况中看到的这些停工,要归因于失误或甚至是非理性的东西。 The abrupt disappearance of stick-spp at the lower speed level is attributed to changes in the elastic deformation of the fiber . 在低速水平时,粘滑现象也消失,这是由于纤维弹性变形的改变。 The stabipty improvement was attributed to the effect of the gelpng agent in the inhibition of fuel atomization and droplet breakup . 稳定性的改善是由于胶化剂在抑制燃料雾化和液滴破裂中的作用所致。 These high mobipties are attributed to a special jumping mechani *** that operates in addition to the usual motion through the solvent . 这种高淌度的原因是,除了一般通过溶剂的运动以外,还有特殊的跳跃机制在起作用。 His conduct, on the unhappy occasion of wilson"s execution, was capable of being attributed to an imprudent excess of zeal in the execution of his duty . 在处理威尔逊的不幸事故中,他的过失可以解释为执行任务时过分轻率的热心。 Where death has been attributed to propoxyphene, the blood levels have a range of 0. 2 to 2. 0 mg/dl, with the majority from 0. 5 to 0. 7 mg/dl . 属于丙氧吩致死的情况下,血液中浓度范围为02-20毫克100毫升,大多数是05-07毫克100毫升。 Something he supposed might be attributed to his connections with them, but yet he had never met with so much attention in the whole course of his pfe . 他想,这件事多少应该归功于他和她们的亲戚关系,可是这样殷勤好客的事,他还是生平第一次碰到呢。 We see the symmetry we have attributed to allypc particles on the basis of the resonance theory; the o ends of each of these molecules are equivalent . 我们看到了曾经根据共振论而归因于烯丙基型粒子的对称性,所有这些分子中每个分子的两端都是等性的。 This play is usually attributed to shakespeare 这个剧本通常认为是莎士比亚作的 Attribute to determine whether themes are supported 属性,以确定是否支持主题。 Attributes to see if they support seriapzation 属性,查看它们是否支持序列化。 Attribute to the property s metadata . visual basic 应用于属性的元数据来定义的。 Assigning permissions and attributes to code groups 将权限和属性分配给代码组。 The damage was obviously attributed to defective packing 显然是因包装而造成货损 Attribute to filter out pnks to the current file 属性过滤出到当前文件的链接。 Used to assign style attributes to html elements 用于将样式属性分配给html元素。 Session attribute to 30 minutes in the web . config file 会话属性设置为30分钟。 Attribute to pnk build providers to the control 属性将生成提供程序链接到控件。 The name of the attribute to use as a sort key 要用作排序关键字的属性的名称。 Attributes to specify additional files and directories 属性指定其他文件和目录。 Attribute to set the description of an assembly 属性以设置有关程序集的说明。 Attribute to specify their cpent - side behavior 属性来指定客户端行为的控件。 An original idea or plan attributed to a person or group 想法计划滑稽古怪的东西 Attribute to the main method of the apppcation 属性应用于应用程序的主方法。 Attribute to specify the language of its inner code 属性来指定其内部代码的语言。 Other possible locking attributes to use are 还可以使用其他可能的锁定属性,如 Deleting unnecessary attributes to delete unnecessary attributes 删除不需要的属性 You can apply attributes to an external reference 可以将属性应用于外部引用。 The following example demonstrates adding new attributes to a 下面的示例说明如何向 This edy has been attributed to shakespeare 这个喜剧据说是莎士比亚所作。 Attribute to platform invoke declarations and the 属性应用于平台调用声明而将 Attribute to a managed interface to specify which 属性应用于一个托管接口以指定哪个 Attribute to specify the namespace , which defaults to 属性指定命名空间(默认为“ Attribute to be called by the asp . runtime 程序集必须让asp . 运行库调用
2023-07-08 07:23:141

Attributes.Add("style","");后面添加的属性会被前面的替代,怎么解决?

用一个字符串拼接起来,if判断完以后再add进去
2023-07-08 07:23:211

yii2 attributes 和load的区别

既然你的id自增主键,那么前端就不应该传递,也就是说写ActiveForm的时候不设置id这条input即可; 如果是其他原因担心id传递过来,可以用函数scenarios()解决; 比如你的model里面有三个字段:id、name、email
2023-07-08 07:23:281

attribute to怎么用?

attribute to意为“归因于,认为是……的结果”;常用作表语或状语。 例:Mr. Dolittle attributes his good health to careful living.  杜德先生把自己的健康体魄归功于审慎的生活方式
2023-07-08 07:23:471

JS中attr和prop属性的区别

对于HTML元素本身就带有的固有属性,在处理时,使用prop方法。对于HTML元素我们自己自定义的DOM属性,在处理时,使用attr方法。举例:<a href="#" id="link1" action="delete">删除</a>这个例子里<a>元素的DOM属性有“href、id和action”,很明显,前两个是固有属性,而后面一个“action”属性是我们自己自定义上去的,<a>元素本身是没有这个属性的。因此获取action使用attr方式获取,其他需要通过prop方式获取补充:在jquery1.6之前的所有版本中都使用attr方法来获取
2023-07-08 07:23:552

workbench目录树中多了CAD+attributes是怎么回事?

从CAD中输入的材料属性将会显示在n “Engineering Data” 目录树下,并分配给相应的零件。 ANSYS Workbench - SimulationTraining ManualJuly 3, 2006Inventory
2023-07-08 07:24:011

yii框架中attributes是什么意思

attributesn. 属性,特性,特质;属性( attribute的名词复数 );(人或物的)特征;价值;[语法学]定语v. 认为…是( attribute的第三人称单数 );把…归于;把…品质归于某人;认为某事[物]属于某人[物]
2023-07-08 07:24:591

Attribute 是VB中的什么属性

Attributes 属性(远程数据) 返回一个值,用以指示 rdoColumn 对象的一个或多个特性。语法object.Attributesobject 所在处是一个对象表达式,其值是“应用于”列表中的一个对象。返回值Attributes 属性的返回值,用以指定由 rdoColumn 对象表示的列的特性
2023-07-08 07:25:061

Android Studio中Attributes被隐藏了,如何显示出Attributes属性

1.打开一个文件夹,在上方“工具”中有一项“文件夹选项”,单击打开。2.打开后单击“查看”项3.在高级设置中找到“隐藏文件和文件夹”单击打开子选项4.选择“显示所有文件和文件夹”,再点确定,回到桌面。5.在桌面右键点“刷新”即可显示出隐藏的文件夹了~~
2023-07-08 07:25:131

Attribute和Property的区别

DOM元素含有的这两个东西,虽然完全不是一回事,但却又紧密联系在一体,不细细体会,还真不好分清。Property-属性,就像C#等高级语言可以.(dot)获取或者设置其值;Attribute-特性,每一个dom元素都有一个attributes属性来存放所有的attribute节点,通过getAttribute()和setAttribute()方法来进行获取和操作。1 <div id="test" name="div1" class="center" customtag="divTest"/>上例中div里面的id、name、class还有自定义的customtag都放到了attributes里面,attributes类似数组的容器,名字索引存放的是name=value的attribute的节点,上面的就是[class="center",name="div1",id="test",customtag="divTest"]需要获取和设置这些attribute,很简单document.getElemmentById("test").getAttribute("customtag") //divTestdocument.getElemmentById("test").setAttribute("data","11")document.getElemmentById("test").removeAttribute("data")Property就是一个属性,如果把DOM元素看成是一个普通的object对象,那么property就是以name=value形式存放在Object中的属性(C#中的类似),操作很简单elem.gameid = 880; // 添加console.log( elem.gameid ) // 获取这两个东西有什么联系和区别呢?首先,很多attribute节点有一个相应的property属性,如例子中的div元素的id和class既是attribute也有property,不管哪种方式都可以访问和修改,但是对于自定义的attribute节点,或者自定义property,两者就没有关系了,对于IE6-7来说,没有区分attribute和property。具体的讲解可以考attribute和property的区别,很详细。虽然getAttribute和点号方法都能获取标准属性,但是他们对于某些属性,获取到的值存在差异性,比如href,src,value等<a href="#" id="link">Test Link</a><img src="img.png" id="image" /><input type="text" value="enter text" id="ipt" /><script>var $ = function(id){return document.getElementById(id);};alert($("link").getAttribute("href"));//#alert($("link").href);//fullpath/file#alert($("image").getAttribute("src"))//img.pngalert($("image").src)//fullpath/img.pngalert($("ipt").getAttribute("value"))//enter textalert($("ipt").value)//enter text$("ipt").value = 5;alert($("ipt").getAttribute("value"))//enter textalert($("ipt").value)//5</script>
2023-07-08 07:25:201

Attributes/Properties这两个单词都叫属性。他们之间的区别

attribute → 指人或物及其地位、属性的象征。properity → 多指同类事物所共有的特性,一般不用于指人
2023-07-08 07:25:271

在哪修改attributes的值为2

select count(*) from v$process --当前的连接数select value from v$parameter where name = "processes" --数据库允许的最大连接数修改最大连接数:alter system set processes = 300 scope = spfile;重启数据库:shutdown immediate;startup;
2023-07-08 07:25:351

physical attributes是什么意思

physical attributes物理属性双语对照词典结果:网络释义1. 物理属性例句:1.Certain physical attributes such as temperature depend on collectivebehavior. 一些物理属性,如温度,也取决于分子的集体行为。.___________________________很高兴为你解答!如有不懂,请追问。 谢谢!
2023-07-08 07:25:542

SetFileAttributes 详细介绍下这个函数

设置文件的属性,比如【只读】【隐藏】等等. 菜单help->windows SDK,输入SetFileAttributes The SetFileAttributes function sets a file"s attributes. BOOL SetFileAttributes( LPCTSTR lpFileName, // address of filename DWORD dwFileAttributes // address of attributes to set );
2023-07-08 07:26:011

nc数据的global attributes是什么意思

nc数据的global attributes是什么意思事件属性:就是当用户操作一个 HTML 元素(如按钮,文本框,选择框等)时,触发某种事件(如点击事件onclick、值变化事件onchange等),从而启动一段 JavaScript动作。常用的事件有几类:1. 窗口事件,如onload(当页面被载入时执行),onunload;2. 表单元素事件,如onchange, onsubmit,onreset,onselect,onblur,onfocus;3. 键盘事件,如onkeydown,onkeypress,onkeyup;4. 鼠标事件,如onclick, ondbclick,onmousedown, onmouseup,onmouseover,onmouseout,onmousemove;等等
2023-07-08 07:26:081

java的Struts配置是什么意思

1)应用前提,attribute只有在设置了name后才有意义。2)attribute可以实现对象的重用,即如果设置了attribute属性,在创建actionform是,会先去查找相应的scope中是否有此对象,如果有,则重用,否则创建新的对象。3)当你将创建的acitonForm保存到相应的scope中时,你想用一个更有意义的名字来访问它时,它就有意义了。可是,看到"一个更有意义的名字的时候", 我好像有点理解了<actionattribute="newLoginForm"name="loginForm"type="loginAction" scope="request"path="/login">在struts实例化actionform的时候,struts是根据attribute的值来查找并创建actionform,有两种情况:如果已经存在,那么从内存中取回;如果第一次实例化,那么创建,并放入内存。org.apache.struts.util.RequestUtils中的源代码 public static Actionform createActionform(HttpServletRequest request,ActionMapping mapping,ModuleConfig moduleConfig,ActionServlet servlet) { ............ ............ String attribute = mapping.getAttribute(); ...... Actionform instance = null;HttpSession session = null; if ("request".equals(mapping.getScope())) {instance = (Actionform) request.getAttribute(attribute);} else {session = request.getSession();instance = (Actionform) session.getAttribute(attribute);} ................ ................ }如果没有配置attribute属性的话, struts才会从name属性里读出要创建的formbean 的名字,并创建一下实例,看下边的源代码就知道了, 呵呵.org.apache.struts.config.ActionConfig protected String attribute = null;public String getAttribute() {//就是这里了. if (this.attribute == null) {return (this.name);} else {return (this.attribute);}}public void setAttribute(String attribute) {if (configured) {throw new IllegalStateException("Configuration is frozen");}this.attribute = attribute;}
2023-07-08 07:26:151

26、BeautifulSoup之Tag

上集回顾: 上集快速领略了一下 BeautifulSoup 的大概功能,并学习了如何安装和构造一个 BeautifulSoup 对象。 本集学习 BeautifulSoup 的 Tag 及其属性。 由于HTML和XML是由大量tag组合和嵌套而成,所以检索目标信息就是检索目标tag的过程。 一、Tag对象 Tag 对象与XML或HTML原生文档中的tag相同: Tag有很多方法和属性,其中最重要的属性是: name和attributes。 二、name属性 每个tag都有自己的名字,通过 .name 来获取: 如果改变了tag的name,那将影响所有通过当前Beautiful Soup对象生成的HTML文档: 三、attributes属性 一个tag可能有很多个属性. tag <b class="boldest"> 有一个 “class” 的属性,值为 “boldest” . tag的属性的操作方法与字典相同: 也可以直接”点”取属性, 比如: .attrs : tag的属性可以被添加,删除或修改. 再说一次, tag的属性操作方法与字典一样 四、多值属性 HTML 定义了一系列可以包含多个值的属性。最常见的多值的属性是 class (一个tag可以有多个CSS的class). 还有一些属性 rel , rev , accept-charset , headers , accesskey 。在Beautiful Soup中多值属性的返回类型是list: 如果某个属性看起来好像有多个值,但在任何版本的HTML定义中都没有被定义为多值属性,那么Beautiful Soup会将这个属性作为字符串返回 将tag转换成字符串时,多值属性会合并为一个值 如果转换的文档是XML格式,那么tag中不包含多值属性 五、字符串 字符串常被包含在tag内。BeautifulSoup用 NavigableString 类来包装tag中的字符串: 一个 NavigableString 字符串与Python中的Unicode字符串相同,通过 unicode() 方法可以直接将 NavigableString 对象转换成Unicode字符串: 本集总结: 下集见
2023-07-08 07:26:221

leadership attributes是什么意思

leadership attributes领袖的特质; 领导特质双语例句1Is it because they were successful at hiring a bunch of peoplewho had strong leadership attributes? 是因为他们成功地雇佣了一群具有强劲领导力的人吗?2Leaders carry out this process by applying their leadershipattributes, such as beliefs, values, ethics, character, knowledge,and skills. 领导者通过应用他们的领导特质如信念、价值观、道德、人格、知识和技能完成领导过程。
2023-07-08 07:26:291

powerdesigner attributes在哪

存储在PowerDesigner的设计元库中,所有的图形都可以直接拷贝到WORD文件中去使用。当然,最正规的做法是:利用PowerDesigner 生成report的功能,把希望输出的内容,包括图形等信息,输出成html 或者 rtf 格式 的文件,就可以有选择地使用其中的各部分内容了。分享
2023-07-08 07:26:361

用IAR嵌入式编译程序,“section=”是什么意思?

#pragma section( "section-name" [, attributes] ) 作用是由程序指定创建一个段一般默认段都是由编译器自动指定的 不过看你这样的写法 IAR的时候是没有默认段的 必须由编写者手动指定比如#pragma section = ".data"就是创建一个名字为.data的段,然后下面调用data_ram = __section_begin(".data");来获取这个段的首地址以备其操作其他类似关于pragma section的详细说明如下。 对于#pragma 预处理还有很多功能 感兴趣可以自行搜索==================================================================================#pragma section。创建一个段。其格式为:#pragma section( "section-name" [, attributes] )section-name是必选项,用于指定段的名字。该名字不能与标准段的名字想冲突。可用/SECTION查看标准段的名称列表。attributes是可选项,用于指定段的属性。可用属性如下,多个属性间用逗号(,)隔开:read:可读取的write:可写的execute:可执行的shared:对于载入该段的镜像的所有进程是共享的nopage:不可分页的,主要用于Win32的设备驱动程序中nocache:不可缓存的,主要用于Win32的设备驱动程序中discard:可废弃的,主要用于Win32的设备驱动程序中remove:非内存常驻的,仅用于虚拟设备驱动(VxD)中如果未指定属性,默认属性为read和write。在创建了段之后,还要使用__declspec(allocate)将代码或数据放入段中。例如://pragma_section.cpp#pragma section("mysec",read,write)int j = 0;__declspec(allocate("mysec"))int i = 0;int main(){}该例中, 创建了段"mysec",设置了read,write属性。但是j没有放入到该段中,而是放入了默认的数据段中,因为它没有使用__declspec(allocate)进行声明;而i放入了该段中,因为使用__declspec(allocate)进行了声明。
2023-07-08 07:26:451

Attributes.Add失效怎么回事?

*号的内容是一定要用js来写的textbox2.visible=true是C#的用法,JS要设置隐藏或者显示是用document.getElementById("textbox2").style.display="none"和document.getElementById("textbox2").style.display=""来设置的这两者的区别是如果设置Visible=false则这个控件在前台页面就会跟本不存在,只有刷新页面才能让其Visible=true而只有用JS设置display才能在不刷新页面的情况下动态设置其显示或隐藏问题二:用onblur事件你要实现的功能代码应该是:textbox1.Attributes.Add("onfocus","document.getElementById("textbox2").style.display="");和textbox1.Attributes.Add("onblur","document.getElementById("textbox2").style.display="none");
2023-07-08 07:26:522

number of attributes是什么意思

number of attributes 属性数量例句筛选1.Invalid number of attributes in input file.在输入文件中有几个无效属性。2.Each type has a number of attributes, which are name-value pairs.Data types of attributes can be每种类型都具有多个属性,这些属性是名称-值对。
2023-07-08 07:26:592

前台怎么取attributes.addflashattribute得值

function test() { var val = document.getElementById("state").value; alert("这里是你要的值:" + val); }
2023-07-08 07:27:171

JS中attr和prop属性的区别

JS中attr和prop属性的区别 相比attr,prop是1.6.1才新出来的,两者从中文意思理解,都是获取/设定属性的方法(attributes和properties)。只是,window或document中使用.attr()方法在jQuery1.6之前不能正常执行,因为window和document中不能有attributes。prop应运而生了。 既然我们想知道他们两的区别,最好就看看他们的原始码,不要被程式码长度所吓到,我们只看关键的几句: attr: function( elem, name, value, pass ) { var ret, hooks, notxml, nType = elem.nodeType; don"t get/set attributes on text, ment and attribute nodes if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { return; } if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) { return jQuery( elem )[ name ]( value ); } Fallback to prop when attributes are not supported if ( typeof elem.getAttribute === "undefined" ) { return jQuery.prop( elem, name, value ); } notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); All attributes are lowercase Grab necessary hook if one is defined if ( notxml ) { name = name.toLowerCase(); hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); } if ( value !== undefined ) { if ( value === null ) { jQuery.removeAttr( elem, name ); return; } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { return ret; } else { elem.setAttribute( name, value + "" ); return value; } } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { return ret; } else { ret = elem.getAttribute( name ); Non-existent attributes return null, we normalize to undefined return ret === null ? undefined : ret; } } prop方法程式码(jQuery版本1.8.3) prop: function( elem, name, value ) { var ret, hooks, notxml, nType = elem.nodeType; don"t get/set properties on text, ment and attribute nodes if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { return; } notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); if ( notxml ) { Fix name and attach hooks name = jQuery.propFix[ name ] || name; hooks = jQuery.propHooks[ name ]; } if ( value !== undefined ) { if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { return ret; } else { return ( elem[ name ] = value ); } } else { if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { return ret; } else { return elem[ name ]; } } } attr方法里面,最关键的两行程式码,elem.setAttribute( name, value + “” )和ret = elem.getAttribute( name ),很明显的看出来,使用的DOM的API setAttribute和getAttribute方法操作的属性元素节点。而prop方法里面,最关键的两行程式码,return ( elem[ name ] = value )和return elem[ name ],你可以理解成这样document.getElementById(el)[name] = value,这是转化成JS物件的一个属性。 既然明白了原理是这样,我们来看看一个例子: <input type=checkbox id="test" abc="111" /> $(function(){ el = $("#test"); console.log(el.attr("style")); undefined console.log(el.prop("style")); CSSStyleDeclaration物件 console.log(document.getElementById("test").style); CSSStyleDeclaration物件 }); el.attr(“style”)输出undefined,因为attr是获取的这个物件属性节点的值,很显然此时没有这个属性节点,自然输出undefinedel.prop(“style”)输出CSSStyleDeclaration物件,对于一个DOM物件,是具有原生的style物件属性的,所以输出了style物件至于document.getElementById(“test”).style和上面那条一样 接着看: el.attr("abc","111") console.log(el.attr("abc")); 111 console.log(el.prop("abc")); undefined 首先用attr方法给这个物件新增abc节点属性,值为111,可以看到的结构也变了 el.attr(“abc”)输出结果为111,再正常不过了el.prop(“abc”)输出undefined,因为abc是在这个的属性节点中,所以通过prop是取不到的 el.prop("abc", "222"); console.log(el.attr("abc")); 111 console.log(el.prop("abc")); 222 我们再用prop方法给这个物件设定了abc属性,值为222,可以看到的结构是没有变化的。输出的结果就不解释了。 上面已经把原理讲清楚了,什么时候用什么就可以自己把握了。 提一下,在遇到要获取或设定checked,selected,readonly和disabled等属性时,用prop方法显然更好,比如像下面这样: <input type=checkbox id="test" checked="checked" />console.log(el.attr("checked")); checked console.log(el.prop("checked")); true console.log(el.attr("disabled")); undefined console.log(el.prop("disabled")); false 显然,布林值比字串值让接下来的处理更合理。 PS一下,如果你有JS效能洁癖的话,显然prop的效能更高,因为attr需要访问DOM属性节点,访问DOM是最耗时的。这种情况适用于多选项全选和反选的情况。 大家都知道有的浏览器只要写disabled,checked就可以了,而有的要写成disabled = "disabled",checked="checked",比如用attr("checked")获取checkbox的checked属性时选中的时候可以取到值,值为"checked"但没选中获取值就是undefined。 jq提供新的方法“prop”来获取这些属性,就是来解决这个问题的,以前我们使用attr获取checked属性时返回"checked"和"",现在使用prop方法获取属性则统一返回true和false。 那么,什么时候使用attr(),什么时候使用prop()?1.新增属性名称该属性就会生效应该使用prop();2.是有true,false两个属性使用prop();3.其他则使用attr();专案中jquery升级的时候大家要注意这点!  window或document中使用.attr()方法在jQuery1.6中不能正常执行,因为window和document中不能有attributes。它们包含properties(比如:location或readyState). 举个简单的例子取值prop("checked")false布林值attr("checked")undefind获取的是字串赋值prop("new-attr",true)attr("new-attr",true)再次获取的prop还是布林值attr还是字串 window或document中使用.attr()方法在jQuery1.6中不能正常执行,因为window和document中不能有attributes。它们包含properties(比如:location或readyState),必须使用.prop()方法操作或简单地使用javascript原生的方法。 在jQuery1.6.1中,wind... window或document中使用.attr()方法在jQuery1.6中不能正常执行,因为window和document中不能有attributes。它们包含properties(比如:location或readyState),必须使用.prop()方法操作或简单地使用javascript原生的方法。 在jQuery1.6.1中,window和document中使用.attr()将被自动转成使用.prop(还没试过)。其次,checked,selected和前面提到的其它boolean attributes,因为这些attributes和其相应的properties之间的特殊关系而被特殊对待。通常,attribute 就是以下程式码中看到的,如: <input type=”checkbox” checked=”checked”> 但它仅表示checked属性在页面载入的时候被设定成预设值或初始值,而不管checkbox元素是否被选中。 而通常 properties 是一个浏览器用来记录当前属性值的东西。正常情况下,properties反映它们相应的attributes。 所以,当用户点选一个checkbox元素或选中一个select元素的一个option时,使得properties保持最新,但对应的attributes却不一定,它仅被浏览器用来储存该属性的初始值。 对于HTML元素本身就带有的固有属性,在处理时,使用prop方法。 对于HTML元素我们自己自定义的DOM属性,在处理时,使用attr方法。 举例: <a href="#" id="link1" action="delete">删除</a> 这个例子里<a>元素的DOM属性有“href、id和action”,很明显,前两个是固有属性,而后面一个“action”属性是我们自己自定义上去的,<a>元素本身是没有这个属性的。 因此获取action使用attr方式获取,其他需要通过prop方式获取 补充: 在jquery1.6之前的所有版本中都使用attr方法来获取 组成他们的字母不同 拼写不同 读音不同 看起来不同
2023-07-08 07:27:541

powerdesigner中设计E-R图中attributes项的Name和Code有什么区别

CODE是实际转换为数据库时的字段名NAME只是做注释用的,让你明白这个字段名是什么意思。
2023-07-08 07:28:021

为什么attributes do not match.present attributes inc

你好!attributes do not match.present attributes inc属性不匹配。目前公司属性
2023-07-08 07:28:091

[C#] File.SetAttributes 里为什么可以用 "|" 来同时设置多个FileAttribute?

FileAttributes.Hidden打印出来看看,应该是个整数。File.SetAttributes(fullPath, File.GetAttributes(fullPath) | FileAttributes.Hidden);这句话就是在原来的属性上再增加隐藏属性
2023-07-08 07:28:171

property数组怎么定义

DOM元素含有的这两个东西,虽然完全不是一回事,但却又紧密联系在一体,不细细体会,还真不好分清。Property-属性,就像C#等高级语言可以.(dot)获取或者设置其值;Attribute-特性,每一个dom元素都有一个attributes属性来存放所有的attribute节点,通过getAttribute()和setAttribute()方法来进行获取和操作。1 <div id="test" name="div1" class="center" customtag="divTest"/>上例中div里面的id、name、class还有自定义的customtag都放到了attributes里面,attributes类似数组的容器,名字索引存放的是name=value的attribute的节点,上面的就是[class="center",name="div1",id="test",customtag="divTest"]需要获取和设置这些attribute,很简单document.getElemmentById("test").getAttribute("customtag") //divTestdocument.getElemmentById("test").setAttribute("data","11")document.getElemmentById("test").removeAttribute("data")Property就是一个属性,如果把DOM元素看成是一个普通的object对象,那么property就是以name=value形式存放在Object中的属性(C#中的类似),操作很简单elem.gameid = 880; // 添加 console.log( elem.gameid ) // 获取这两个东西有什么联系和区别呢?首先,很多attribute节点有一个相应的property属性,如例子中的div元素的id和class既是attribute也有property,不管哪种方式都可以访问和修改,但是对于自定义的attribute节点,或者自定义property,两者就没有关系了,对于IE6-7来说,没有区分attribute和property。具体的讲解可以考attribute和property的区别,很详细。虽然getAttribute和点号方法都能获取标准属性,但是他们对于某些属性,获取到的值存在差异性,比如href,src,value等<a href="#" id="link">Test Link</a><img src="img.png" id="image" /><input type="text" value="enter text" id="ipt" /><script>var $ = function(id){return document.getElementById(id);};alert($("link").getAttribute("href"));//#alert($("link").href);//fullpath/file.html#alert($("image").getAttribute("src"))//img.pngalert($("image").src)//fullpath/img.pngalert($("ipt").getAttribute("value"))//enter textalert($("ipt").value)//enter text$("ipt").value = 5;alert($("ipt").getAttribute("value"))//enter textalert($("ipt").value)//5</script>
2023-07-08 07:28:241