jQuery 未定义的属性名(角色),eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26209286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 11:14:34  来源:igfitidea点击:

Undefined attribute name (role) , eclipse

jqueryeclipsetwitter-bootstrapundefined

提问by NNikN

I have a following file structure

我有以下文件结构

WebContent->bootstrap->

WebContent->引导程序->

js

js

css

css

img

图片

WebContent->index.jsp

WebContent->index.jsp

None of the following two urls are helping to resolve undefined attribute error.

以下两个 url 都没有帮助解决未定义的属性错误。

Undefined attribute name (data-toggle)

未定义的属性名称(数据切换)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">

<button type="submit" class="btn btn-default">Submit</button>
<span class="label label-primary">Primary</span>
<span class="label label-success">Success</span>
<span class="label label-info">Info</span>
<span class="label label-warning">Warning</span>
<span class="label label-danger">Danger</span>
<a href="#">Inbox <span class="badge">42</span></a>


</div>
<div class="jumbotron">
  <h1>Hello, world!</h1>
  <p>...</p>
  <p><a class="btn btn-primary btn-lg" role="button">Learn more</a></p>
</div>

<div class="dropdown">
  <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
    Dropdown
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
    <li role="presentation" class="divider"></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
  </ul>
</div>
</body>
</html>

Eclipse version details are listed below. Spring Tool Suite

下面列出了 Eclipse 版本的详细信息。弹簧工具套件

Version: 3.6.1.RELEASE Build Id: 201408250818 Platform: Eclipse Luna (4.4)

版本:3.6.1.RELEASE Build Id:201408250818 平台:Eclipse Luna (4.4)

Copyright (c) 2007 - 2014 Pivotal Software, Inc. All rights reserved. Visit http://spring.io/tools/sts

版权所有 (c) 2007 - 2014 Pivotal Software, Inc。保留所有权利。访问http://spring.io/tools/sts

This product includes software developed by the Apache Software Foundation http://www.apache.org

本产品包括由 Apache 软件基金会开发的软件http://www.apache.org

回答by cvrebert

Your doctype

你的文档类型

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

is for HTML 4.01.

适用于 HTML 4.01。

data-*attributeswere added in HTML 5. The doctype for HTML 5is basically either

data-*在 HTML 5 中添加了属性。 HTML 5的文档类型基本上是

<!DOCTYPE html>

or

或者

<!DOCTYPE html SYSTEM "about:legacy-compat">

It's also quite possible that your IDE isn't aware of HTML 5 and its many changes.

您的 IDE 也很可能不知道 HTML 5 及其许多更改。

回答by MS Ibrahim

Newer versions of Eclipse support HTML5 tags and the data-* attributes allowed in HTML5. However, when using the role attribute the proper syntax according to the ARIA Roles Model and XHTML Role Attribute Module is not to prefix the role attribute with data-* leaving just role and not data-role.

较新版本的 Eclipse 支持 HTML5 标记和 HTML5 中允许的 data-* 属性。然而,当使用角色属性时,根据 ARIA 角色模型和 XHTML 角色属性模块的正确语法是不要在角色属性前加上 data-*,只留下角色而不是数据角色。

So <ul role="menubar">is more correct than <ul data-role="menubar">. The validity of the syntax can be checked using the (X)HTML5 Validator. jQuery Mobile uses quite extensively the data-role attribute, though I'm not sure why.

所以<ul role="menubar">比 更正确<ul data-role="menubar">。可以使用 (X)HTML5 Validator 检查语法的有效性。jQuery Mobile 非常广泛地使用 data-role 属性,但我不知道为什么。

Note: If you upgrade and you're still getting warnings on data-* attributes you may want to consider updating or removing any installed syntax-checkers such as JTidy. As of Indigo Service Release 1 the role attribute continues to trigger an undefined attribute warning in Eclipse by default.

注意:如果升级后仍然收到有关 data-* 属性的警告,您可能需要考虑更新或删除任何已安装的语法检查程序,例如 JTidy。从 Indigo Service Release 1 开始,默认情况下,角色属性继续在 Eclipse 中触发未定义属性警告。

回答by peacefull warrior

I had the same problem with Eclipse-Helios, here's what i did:

我在 Eclipse-Helios 上遇到了同样的问题,这就是我所做的:

From the tool bar:

从工具栏:

Window>preferences>Web>Validation>Attributes,

窗口>首选项>Web>验证>属性,

Then change

然后改变

"Undefined attribute name"

“未定义的属性名称”

from

'error'

'错误'

or

或者

'warning'

'警告'

to

'ignore'

'忽略'

.

.

helios.png

太阳神.png