(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.echarts = {})));
}(this, (function (exports) { 'use strict';
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// (1) The code `if (__DEV__) ...` can be removed by build tool.
// (2) If intend to use `__DEV__`, this module should be imported. Use a global
// variable `__DEV__` may cause that miss the declaration (see #6535), or the
// declaration is behind of the using position (for example in `Model.extent`,
// And tools like rollup can not analysis the dependency if not import).
var dev;
// In browser
if (typeof window !== 'undefined') {
dev = window.__DEV__;
}
// In node
else if (typeof global !== 'undefined') {
dev = global.__DEV__;
}
if (typeof dev === 'undefined') {
dev = true;
}
var __DEV__ = dev;
/**
* zrender: 生成唯一id
*
* @author errorrik (errorrik@gmail.com)
*/
var idStart = 0x0907;
var guid = function () {
return idStart++;
};
/**
* echarts设备环境识别
*
* @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
* @author firede[firede@firede.us]
* @desc thanks zepto.
*/
/* global wx */
var env = {};
if (typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function') {
// In Weixin Application
env = {
browser: {},
os: {},
node: false,
wxa: true, // Weixin Application
canvasSupported: true,
svgSupported: false,
touchEventsSupported: true,
domSupported: false
};
}
else if (typeof document === 'undefined' && typeof self !== 'undefined') {
// In worker
env = {
browser: {},
os: {},
node: false,
worker: true,
canvasSupported: true,
domSupported: false
};
}
else if (typeof navigator === 'undefined') {
// In node
env = {
browser: {},
os: {},
node: true,
worker: false,
// Assume canvas is supported
canvasSupported: true,
svgSupported: true,
domSupported: false
};
}
else {
env = detect(navigator.userAgent);
}
var env$1 = env;
// Zepto.js
// (c) 2010-2013 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.
function detect(ua) {
var os = {};
var browser = {};
// var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
// var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
// var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
// var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
// var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
// var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
// var touchpad = webos && ua.match(/TouchPad/);
// var kindle = ua.match(/Kindle\/([\d.]+)/);
// var silk = ua.match(/Silk\/([\d._]+)/);
// var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
// var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
// var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
// var playbook = ua.match(/PlayBook/);
// var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
var firefox = ua.match(/Firefox\/([\d.]+)/);
// var safari = webkit && ua.match(/Mobile\//) && !chrome;
// var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
var ie = ua.match(/MSIE\s([\d.]+)/)
// IE 11 Trident/7.0; rv:11.0
|| ua.match(/Trident\/.+?rv:(([\d.]+))/);
var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
var weChat = (/micromessenger/i).test(ua);
// Todo: clean this up with a better OS/browser seperation:
// - discern (more) between multiple browsers on android
// - decide if kindle fire in silk mode is android or not
// - Firefox on Android doesn't specify the Android version
// - possibly devide in os, device and browser hashes
// if (browser.webkit = !!webkit) browser.version = webkit[1];
// if (android) os.android = true, os.version = android[2];
// if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
// if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
// if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
// if (webos) os.webos = true, os.version = webos[2];
// if (touchpad) os.touchpad = true;
// if (blackberry) os.blackberry = true, os.version = blackberry[2];
// if (bb10) os.bb10 = true, os.version = bb10[2];
// if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
// if (playbook) browser.playbook = true;
// if (kindle) os.kindle = true, os.version = kindle[1];
// if (silk) browser.silk = true, browser.version = silk[1];
// if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
// if (chrome) browser.chrome = true, browser.version = chrome[1];
if (firefox) {
browser.firefox = true;
browser.version = firefox[1];
}
// if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
// if (webview) browser.webview = true;
if (ie) {
browser.ie = true;
browser.version = ie[1];
}
if (edge) {
browser.edge = true;
browser.version = edge[1];
}
// It is difficult to detect WeChat in Win Phone precisely, because ua can
// not be set on win phone. So we do not consider Win Phone.
if (weChat) {
browser.weChat = true;
}
// os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
// (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
// os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos ||
// (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
// (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
return {
browser: browser,
os: os,
node: false,
// 原生canvas支持,改极端点了
// canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
canvasSupported: !!document.createElement('canvas').getContext,
svgSupported: typeof SVGRect !== 'undefined',
// works on most browsers
// IE10/11 does not support touch event, and MS Edge supports them but not by
// default, so we dont check navigator.maxTouchPoints for them here.
touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
// <http://caniuse.com/#search=pointer%20event>.
pointerEventsSupported:
// (1) Firefox supports pointer but not by default, only MS browsers are reliable on pointer
// events currently. So we dont use that on other browsers unless tested sufficiently.
// For example, in iOS 13 Mobile Chromium 78, if the touching behavior starts page
// scroll, the `pointermove` event can not be fired any more. That will break some
// features like "pan horizontally to move something and pa
jquery-3.3.1.js
需积分: 0 157 浏览量
更新于2023-06-06
收藏 721KB ZIP 举报
《jQuery 3.3.1 JavaScript 库深度解析与应用》
jQuery,作为一款轻量级的JavaScript库,自2006年发布以来,因其简洁的API和强大的功能,深受开发者喜爱。本文将深入探讨jQuery 3.3.1版本中的核心特性,并结合其在实际项目中的应用,为开发者提供全面的参考。
一、jQuery简介
jQuery由John Resig创建,旨在简化HTML文档遍历、事件处理、动画和Ajax交互。它的主要特点包括选择器、DOM操作、事件绑定和动画效果等。jQuery 3.3.1是该库的一个稳定版本,对性能进行了优化,并修复了若干已知问题。
二、jQuery 3.3.1的核心特性
1. **选择器**: jQuery提供了丰富的CSS选择器,如ID选择器(#id)、类选择器(.class)、元素选择器(element)等,以及组合选择器,如后代选择器、子元素选择器、相邻兄弟选择器等,使得DOM元素的选取变得简单直观。
2. **DOM操作**: jQuery提供了一系列方法来操作DOM,如`$(selector).append()`用于在元素末尾添加内容,`$(selector).remove()`用于删除元素,`$(selector).html()`则用于获取或设置元素的HTML内容。
3. **事件处理**: jQuery的事件处理机制简化了原生JavaScript的事件绑定。例如,`$(selector).click(function(){...})`可以为指定元素添加点击事件,`$(selector).on('event', function(){...})`则支持动态绑定事件。
4. **动画效果**: jQuery的动画功能强大,如`fadeIn()`, `slideUp()`, `animate()`等,能够轻松实现平滑的页面过渡效果。
三、jQuery 3.3.1的性能优化
在jQuery 3.3.1版本中,开发团队专注于性能提升,减少了DOM操作的开销,提高了代码执行效率。此外,该版本还移除了对旧版IE浏览器的支持,进一步降低了代码复杂性。
四、jQuery与其他库的协同——以echarts.js为例
echarts.js是一款基于JavaScript的数据可视化库,可与jQuery无缝集成。在数据可视化项目中,我们可以利用jQuery来处理DOM元素,而使用echarts进行图表绘制。例如,首先通过jQuery获取图表容器:
```javascript
var chartContainer = $('#chart');
```
然后,初始化echarts实例:
```javascript
var myChart = echarts.init(chartContainer[0]);
```
配置图表选项并加载数据:
```javascript
var option = {
// 配置项...
};
myChart.setOption(option);
```
通过这样的方式,jQuery和echarts.js的结合可以实现高效且美观的数据展示。
五、jQuery的应用场景
jQuery广泛应用于网页动态交互、响应式设计、表单验证、AJAX请求等多个领域。例如,在前后端分离的项目中,jQuery可以方便地处理异步请求,如`$.ajax()`或`$.get()`, `$.post()`等,使数据交互更加流畅。
六、未来发展趋势
虽然随着现代前端框架(如React, Vue, Angular)的兴起,jQuery的使用频率有所下降,但它仍然在许多传统项目和小型应用中占据重要地位。开发者可以根据项目需求,灵活选择jQuery与其他库的配合使用,以达到最佳效果。
总结,jQuery 3.3.1以其强大的功能和易用性,依然是许多开发者首选的JavaScript库之一。了解并掌握其核心特性和应用场景,对于提高开发效率和项目质量具有重要意义。同时,合理地与其他库(如echarts.js)结合,可以更好地满足项目需求,创造出更优秀的用户体验。