1. <tfoot id='4kyNk'></tfoot>
      2. <i id='4kyNk'><tr id='4kyNk'><dt id='4kyNk'><q id='4kyNk'><span id='4kyNk'><b id='4kyNk'><form id='4kyNk'><ins id='4kyNk'></ins><ul id='4kyNk'></ul><sub id='4kyNk'></sub></form><legend id='4kyNk'></legend><bdo id='4kyNk'><pre id='4kyNk'><center id='4kyNk'></center></pre></bdo></b><th id='4kyNk'></th></span></q></dt></tr></i><div id='4kyNk'><tfoot id='4kyNk'></tfoot><dl id='4kyNk'><fieldset id='4kyNk'></fieldset></dl></div>
      3. <legend id='4kyNk'><style id='4kyNk'><dir id='4kyNk'><q id='4kyNk'></q></dir></style></legend>
        • <bdo id='4kyNk'></bdo><ul id='4kyNk'></ul>

        <small id='4kyNk'></small><noframes id='4kyNk'>

      4. 我什么时候应该使用 javascript 框架库?

        When should I use a javascript framework library?(我什么时候应该使用 javascript 框架库?)
        <i id='JmxY2'><tr id='JmxY2'><dt id='JmxY2'><q id='JmxY2'><span id='JmxY2'><b id='JmxY2'><form id='JmxY2'><ins id='JmxY2'></ins><ul id='JmxY2'></ul><sub id='JmxY2'></sub></form><legend id='JmxY2'></legend><bdo id='JmxY2'><pre id='JmxY2'><center id='JmxY2'></center></pre></bdo></b><th id='JmxY2'></th></span></q></dt></tr></i><div id='JmxY2'><tfoot id='JmxY2'></tfoot><dl id='JmxY2'><fieldset id='JmxY2'></fieldset></dl></div>

        <small id='JmxY2'></small><noframes id='JmxY2'>

        <tfoot id='JmxY2'></tfoot>
          <bdo id='JmxY2'></bdo><ul id='JmxY2'></ul>

                <tbody id='JmxY2'></tbody>
              <legend id='JmxY2'><style id='JmxY2'><dir id='JmxY2'><q id='JmxY2'></q></dir></style></legend>
                  本文介绍了我什么时候应该使用 javascript 框架库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在编写一个小型网站,它只是制作一些动画并将一些信息显示为主页和链接列表.所有这些都将在客户端动态生成.所以一切都将是 javascript 和 XML.

                  最近我一直在阅读 SO 中有关 javascript 的一些问题,并且大多数情况涉及框架的使用和/或推荐(jquery 和朋友).小型 Web 开发何时应该开始考虑使用这样的框架?

                  到目前为止,我一直只使用普通的 javascript 来做我的事情,就我没有实现大型网站而言,是否值得学习一个框架?

                  谢谢

                  解决方案

                  在 SO 上你会发现 很多 人(包括我)提倡使用 jQuery(尤其是).对我来说,这是一个框架应该具备的一切:小型、轻量级、可扩展、紧凑但功能强大且语法简洁,它解决了一些非常重要的问题.老实说,我很难想象一个我不会使用它(或其他框架)的项目.

                  使用它的原因是为了解决浏览器的兼容性问题.考虑我对 javascript 获取段落的回答网页中所选文本的数量:

                  <块引用>

                  函数 getSelectedParagraphText() {var 用户选择;如果(window.getSelection){选择 = window.getSelection();} else if (document.selection) {选择 = document.selection.createRange();}var parent = selection.anchorNode;while (parent != null && parent.localName != "P") {父 = 父节点;}如果(父母==空){返回 "";} 别的 {返回 parent.innerText ||父.文本内容;}}

                  如果您熟悉 Javascript,那么您应该熟悉其中的很多内容:检查 innerText 或 textContent (Firefox 1.5) 等等.纯 Javascript 充斥着这样的东西.现在考虑 jQuery 解决方案:

                  函数 getSelectedParagraphText() {var 用户选择;如果(window.getSelection){选择 = window.getSelection();} else if (document.selection) {选择 = document.selection.createRange();}var parent = selection.anchorNode;var paras = $(parent).parents("p")返回 paras.length == 0 ?"" : paras.text();}

                  jQuery 真正闪耀的地方在于 AJAX.周围有 JavaScript 代码片段来找到正确的对象来实例化(XMLHttpRequest 或等效的)来执行 AJAX 请求.jQuery 会为您处理所有这些.

                  对于核心 jQuery Javascript 文件,所有这些都在 20k 以下.对我来说,这是必须的.

                  I'm writing a small web that just makes some animation and shows some information as a homepage and a list of links. All that is going to be generated dynamically in the client side. So everything is going to be javascript and XML.

                  Recently I've been reading some questions in SO about javascript, and most of the situations involved the use and/or recommendation of a framework (jquery and friends). When a small web development should start considering the use of such a framework?

                  I've been until now doing my stuff just with plain javascript, as far as I'm not implementing a big site is it worth the learning a framework?

                  Thanks

                  解决方案

                  On SO you will find a lot of people (including me) who advocate the use of jQuery (in particular). To me, it's everything a framework should be: small, lightweight, extensible, compact yet powerful and brief syntax and it solves some pretty major problems. I would honestly have a hard time trying to envision a project where I wouldn't use it (or another framework).

                  The reason to use it is to solve browser compatibility issues. Consider my answer to javascript to get paragraph of selected text in web page:

                  function getSelectedParagraphText() {
                    var userSelection;
                    if (window.getSelection) {
                        selection = window.getSelection();
                    } else if (document.selection) {
                        selection = document.selection.createRange();
                    }
                    var parent = selection.anchorNode;
                    while (parent != null && parent.localName != "P") {
                      parent = parent.parentNode;
                    }
                    if (parent == null) {
                      return "";
                    } else {
                      return parent.innerText || parent.textContent;
                    }
                  }
                  

                  If you're familiar with Javascript a lot of this should be familiar to you: things like the check for innerText or textContent (Firefox 1.5) and so on. Pure Javascript is littered with things like this. Now consider the jQuery solution:

                  function getSelectedParagraphText() {
                    var userSelection;
                    if (window.getSelection) {
                        selection = window.getSelection();
                    } else if (document.selection) {
                        selection = document.selection.createRange();
                    }
                    var parent = selection.anchorNode;
                    var paras = $(parent).parents("p")
                    return paras.length == 0 ? "" : paras.text();
                  }
                  

                  Where jQuery really shines though is with AJAX. There JavaScript code snippets around to find the correct object to instantiate (XMLHttpRequest or equivalent) to do an AJAX request. jQuery takes care of all that for you.

                  All of this for under 20k for the core jQuery Javascript file. To me, it's a must-have.

                  这篇关于我什么时候应该使用 javascript 框架库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                  Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                  Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                  Explain about async/ await in Protractor(解释 Protractor 中的 async/await)
                  Protractor browser.wait doesn#39;t wait(量角器 browser.wait 不等待)
                  How to use Protractor with Angular 2?(如何在 Angular 2 中使用量角器?)
                    <tbody id='rHzQt'></tbody>

                    <i id='rHzQt'><tr id='rHzQt'><dt id='rHzQt'><q id='rHzQt'><span id='rHzQt'><b id='rHzQt'><form id='rHzQt'><ins id='rHzQt'></ins><ul id='rHzQt'></ul><sub id='rHzQt'></sub></form><legend id='rHzQt'></legend><bdo id='rHzQt'><pre id='rHzQt'><center id='rHzQt'></center></pre></bdo></b><th id='rHzQt'></th></span></q></dt></tr></i><div id='rHzQt'><tfoot id='rHzQt'></tfoot><dl id='rHzQt'><fieldset id='rHzQt'></fieldset></dl></div>

                      • <bdo id='rHzQt'></bdo><ul id='rHzQt'></ul>
                      • <small id='rHzQt'></small><noframes id='rHzQt'>

                        <legend id='rHzQt'><style id='rHzQt'><dir id='rHzQt'><q id='rHzQt'></q></dir></style></legend>

                          1. <tfoot id='rHzQt'></tfoot>