问题描述
AngularJS是否启用JavaScript的依赖。这意味着,如果有人访问内置AngularJS应用程序或网站将无法正常渲染。
AngularJS is dependent upon JavaScript being enabled. This means that if someone visits an application or website built in AngularJS it will not render properly.
什么是用于处理JavaScript的游客共同约定禁用使用AngularJS什么时候?
What are common conventions used to handle visitors with JavaScript disabled when using AngularJS?
请解释为什么是这样?
是处理棱角分明JS指令和{{data_bindings}}的情况。以使数据不显示当页面不能呈现页面。
Included in the problem is the case of handling angular JS directives and {{data_bindings}}. So that the data does not show when the page cannot render the page.
推荐答案
在这个问题上考虑其他的答案,之后的检测以及对AngularJS一些进一步的研究。
After considering other answers on this question and "How to detect if JavaScript is disabled?" as well as some further research on AngularJS.
首先你要隐藏通过数据绑定显示所有变量。
First off you will want to hide all variables displayed through the databindings.
这可以用它附加到HTML标记来完成。
This can be done using ng-cloak which is appended to an HTML tag.
<div ng-cloak>
<!-- page content here -->
{{bound_data}}
</div>
它还包括一个CSS标签来隐藏元素。
It also includes a CSS tag to hide that element.
[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak {
display: none !important;
}
您随后将要显示替代内容为当用户的JavaScript阻止或禁用。这是通过使用标签来实现的。
You will then want alternate content to be displayed for when a user has JavaScript blocked or disabled. This is done using the tag.
<noscript>
You must have JavaScript enabled to use this app.
</noscript>
您可以选择创建与减少的特性和功能,或者要求访问者的应用程序,以便在所有使用你的应用程序中启用JavaScript。
You have the choice to create an app with reduced features and functionality or require the visitor to have JavaScript enabled in order to use your app at all.
这篇关于如何处理JavaScript在AngularJS被禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!