


Usage examples of Taobao travel universal calendar component implemented in javascript_javascript skills
本文实例讲述了javascript实现的淘宝旅行通用日历组件用法。分享给大家供大家参考。
在线演示:http://demo.jb51.net/js/2015/trip-calendar/demo.html
PS:下面的演示代码,需要用到 trip-calendar.js与trip-calendar.css文件。打包下载地址
具体如下:
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <meta name="author" content="angtian"> <meta name="description" content="淘宝旅行通用日历组件Demo1"> <meta name ="keywords" content="日历, 日历组件, 淘宝旅行日历"> <title>淘宝旅行通用日历组件Demo1</title> <style> body{padding:0;margin:0 10px;text-align:center;} .title{padding:0;margin:10px 0;font:700 18px/1.5 \5fae\8f6f\96c5\9ed1;} .title a{font:400 14px/1.5 Tahoma;margin-left:20px;} .example{margin-top:10px;} .example button{margin:0 5px 10px 0;} .calendar{display:inline-block;} </style> <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script> <script> var root = 'http://fgm.cc/learn/calendar/trip-calendar/'; YUI({ modules: { 'trip-calendar': { fullpath: root + 'trip-calendar.js', type : 'js', requires: ['trip-calendar-css'] }, 'trip-calendar-css': { fullpath: root + 'trip-calendar.css', type : 'css' } } }).use('trip-calendar', function(Y) { /** * 非弹出式日历实例 * 直接将日历插入到页面指定容器内 */ var oCal = new Y.TripCalendar({ container : '#J_Calendar', //非弹出式日历时指定的容器(必选) selectedDate: new Date //指定日历选择的日期 }); //日期点击事件 oCal.on('dateclick', function() { var selectedDate = this.get('selectedDate'); alert(selectedDate + '\u3010' + this.getDateInfo(selectedDate) + '\u3011'); }); Y.one('#J_Example').delegate('click', function(e) { var oTarget = e.currentTarget; value = oTarget.getAttribute('data-value'); switch(true) { //日历个数 case oTarget.hasClass('J_Count'): this.set('count', value).render(); break; //显示节假日 case oTarget.hasClass('J_showHoliday'): this.set('isHoliday', true).render(); break; //隐藏节假日 case oTarget.hasClass('J_hideHoliday'): this.set('isHoliday', false).render(); break; //时间范围限定 case oTarget.hasClass('J_Limit'): this.set('minDate', new Date) .set('maxDate', '') .set('afterDays', value) .set('date', new Date()); break; //指定初始日期 case oTarget.hasClass('J_InitDate'): this.set('minDate', value) .set('maxDate', '2012-12-21') .set('date', value); break; //下拉表单选择时间 case oTarget.hasClass('J_Select'): this.set('isSelect', true).render(); Y.all('.J_Count').slice(1).set('disabled', true); break; //取消下拉表单选择 case oTarget.hasClass('J_SelectOff'): this.set('isSelect', false).render(); Y.all('.J_Count').slice(1).set('disabled', false); break; } }, 'button', oCal); }); </script> </head> <body> <h1 id="淘宝旅行通用日历组件Demo-a-href-http-fgm-cc-learn-calendar-trip-calendar-Demo-html-Demo-a-a-href-http-fgm-cc-learn-calendar-trip-calendar-Demo-html-Demo-a-a-href-http-fgm-cc-learn-calendar-trip-calendar-Demo-html-Demo-a-a-href-http-fgm-cc-learn-calendar-trip-calendar-api-html-target-blank-API文档-a">淘宝旅行通用日历组件Demo1 <a href="http://fgm.cc/learn/calendar/trip-calendar/Demo1.html">Demo1</a><a href="http://fgm.cc/learn/calendar/trip-calendar/Demo2.html">Demo2</a><a href="http://fgm.cc/learn/calendar/trip-calendar/Demo3.html">Demo3</a><a href="http://fgm.cc/learn/calendar/trip-calendar/api.html" target="_blank">API文档</a></h1> <div id="J_Example" class="example"> <button class="J_Count" data-value="1">单日历</button> <button class="J_Count" data-value="2">双日历</button> <button class="J_Count" data-value="3">三日历</button> <button class="J_Count" data-value="4">四日历</button> <br /> <button class="J_showHoliday">显示节假日</button> <button class="J_hideHoliday">隐藏节假日</button> <br /> <button class="J_Limit" data-value="90">限定范围(今天->90天)</button> <button class="J_InitDate" data-value="2012-10-01">指定初始日期(2012年10月)</button> <button class="J_InitDate" data-value="">取消范围限定</button> <br /> <button class="J_Select">下拉表单选择时间</button> <button class="J_SelectOff">取消下拉表单选择</button> </div> <div id="J_Calendar" class="calendar"></div> </body> </html>
希望本文所述对大家的javascript程序设计有所帮助。

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
