• <tfoot id='fuX9Z'></tfoot>

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

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

      • <bdo id='fuX9Z'></bdo><ul id='fuX9Z'></ul>

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

        时间:2023-10-11
        <tfoot id='SDiox'></tfoot>

          <bdo id='SDiox'></bdo><ul id='SDiox'></ul>

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

              <tbody id='SDiox'></tbody>

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

                1. <legend id='SDiox'><style id='SDiox'><dir id='SDiox'><q id='SDiox'></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 框架库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:框架和工具包之间的主要区别是什么? 下一篇:AngularJS 指令中的两种数据绑定方式

                  相关文章

                  最新文章

                2. <tfoot id='6sJed'></tfoot>

                  <small id='6sJed'></small><noframes id='6sJed'>

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