我应该关心 W3C 验证吗? [英] Should I care about W3C validation?

查看:20
本文介绍了我应该关心 W3C 验证吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 AngularJS,我发现了一个像这样的简单代码:

I'm learning AngularJS and I found a simple code like this one:

<!DOCTYPE html>
<html>
   <head>
    <meta charset='utf-8'>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"></script>
</head>
<body ng-app ng-init="name = 'World'">
    <h1>Hello, {{name}}!</h1>
</body>
</html>

没有通过W3C验证测试,主要是因为有非标准属性(ng-appng-init).

does not pass W3C validation test, mainly because there are non standard attributes (ng-app, ng-init).

问题是:我应该关心我的应用程序的 W3C 验证吗?我应该放弃 AngularJS 吗?

The question is: should I care about W3C validation of my application? Should I abandon AngularJS?

推荐答案

您可以使用标准的 data- html5 属性,据我所知,它对 Angular 的作用相同.类似的东西:

You could use the data- html5 attribute which is standard and as far as I know works the same for Angular. Something like:

data-ng-app=""
data-ng-init="xxx"

在 Angular 中的工作方式相同,并由 W3C 验证.

Will work the same in Angular and are validated by W3C.

也看看这个:ng-app vs.data-ng-app,有什么区别?

除此之外,根据我的经验,如果您的产品将交付给具有不同客户端、版本等的可能的大量人群(因此您正在构建网站或公共网络应用程序等),则使用标准总是更好.如果您正在使用 angular 和 phonegap 构建一个 SPA 来创建一个移动应用程序,该应用程序将作为本机应用程序安装在移动设备上,那么标准就没有那么重要了,重要的是它可以在您的目标设备上运行.

Aside from that, from my experience working with standards is always better when your product will be delivered to a possible large crowd (so you'r building a website or a public webapp and so on) with different clients, versions etc. If you're building a SPA using angular and maybe phonegap to create a mobile app which will be installed on mobile devices as a native app, standard could not be that important, the important thing is that it will work on your target devices.

这篇关于我应该关心 W3C 验证吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆