首页 文章 精选 留言 我的

精选列表

搜索[前端统一],共10000篇文章
优秀的个人博客,低调大师

Web 新平台 “airoot-uisys” 释放前端开发活力

写这篇文章比较尴尬,因为当今开发WEB的平台主要是nodejs,代表性的框架就是网络三大框架。很多人都了解也都熟悉,他们的优势之一就是模块化开发,适合大项目的构架,另外就是数据绑定的思想。我开发WEB大概很长时间了,之前前身做flash,后来做flex,用过extjs、j-ui,当然web三大框架都用过,说实话对于开发来讲还是限制性比较大。由衷的感觉早起开发WEB像拿着画笔,现在开发WEB像拿着印刷机。虽然web开发当今蓬勃发展,丹内在确实siqichenc死气沉沉,没有创意和灵感。 因此,我重新开发了一套工具,这套工具给程序员更自由的发挥空间,并且无论开发者在什么水平,都可以轻易实现模块化的思想。在这套工具里,及时你会最简单的html开发,也不影响你循序渐进的使用。 那么下面看下在套工具的能力:我们用React写个例子: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Hello React!</title> <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script> <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script> <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="example"></div> <script type="text/babel"> <!-- 定义一个模块 --> function Element(){ return <h1>Hello Baby!</h1>; } <!-- 你要展现的代码写在下面. --> function App(props) { return ( <div> <Element/> <Element/> </div> ); } ReactDOM.render( <App />, document.getElementById('example') ); </script> </body> </html> 看下 airoot-uisys 工具下的写法(其中@pub 表示可以单页渲染)。 <@pub/> <!-- 定义一个模块 --> <@define name="Element"> <h1>Hello Baby!</h1> </@define> <!-- 你要展现的代码写在下面. --> <div> <Element/> <Element/> </div> 如果要运行上面的代码,可以看下这个博客:https://cloud.tencent.com/developer/article/1611252 你也可通过javascript 创建自定义的component看下React的实现: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Hello React!</title> <script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script> <script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script> <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script> </head> <body> <div id="example"></div> <script type="text/babel"> <!-- 定义一个模块 --> function Element(){ return <h1>Hello Baby!</h1>; } <!-- 定义一个模块 --> class App extends React.Component{ constructor(props) { super(props); this.state = {comps : [1]} } render() { const {comps } = this.state; return ( <div> {comps.map(comp => { return <Element/> })} </div> ); } } ReactDOM.render( <App />, document.getElementById('example') ); </script> </body> </html> 看下uisys的实现: <@pub/> <!-- 定义一个模块 --> <@define name="Element"> <h1>Hello Baby!</h1> </@define> <!-- 你要展现的代码写在下面. --> <div> <!-- dom 内部区域--> </div> <script> function init(){ var element = new Element(); dom.appendChild(element); } </script> 上面的代码如果不了解dom关键字,你也可以这么写: <@pub/> <!-- 定义一个模块 --> <@define name="Element"> <div>Hello Baby!</div> </@define> <!-- 你要展现的代码写在下面. --> <div id="ct"></div> <script> function init(){ var element= new Element(); #ct.appendChild(element); } </script> uisys 的灵活性非常好,上面的代码你可以分成两个文件,一个放Element.ui ,一个放App.ui。这里就不多演示了。 airoot uisys 现在发布了v1版本,基于它的能力可以创建很多复杂的web应用。例如可以用HTML渲染Three.js 的功能,如下效果图: 其他如下: <!-- 类注释 @author sunxy @version 0.0 --> <@import value="jus.*" /> <@import value="zs.*" /> <@import value="zs.texture.*" /> <desktop> <style> *{ transition:all .3s ease; } #header{ background-color:#f0f0f0; } #header ul{ margin-top:20px; margin-right:20px; } #header li{ float:left; list-style:none; margin-right:10px; } </style> <hbox id="header" width="100%" height="60"> <div width="400" height="100%" style="font-family:Microsoft YaHei;font-size:32px;font-weight:bold;margin:10px 0px 0px 15px;">AIroot Library Manager</div> <div width="100%" height="100%"> <ul style="float:right;"> <li>HOME</li> <li>ABOUT</li> <li>EDIT</li> <li>SERVICE</li> </ul> </div> </hbox> <position width="100%" height="100%"> <td id="plt" width="100%" height="100%"> <SkyBox> <children> <Sphere x="0" y="0" z="0" r="3" w="26" h="24" color="#ffaa00" /> <Sphere x="10" y="0" z="0" r="3" w="26" h="24" color="#00ffaa"/> <Sphere x="0" y="10" z="0" r="3" w="26" h="24" color="#ff00aa"/> <Sphere x="0" y="0" z="10" r="3" w="26" h="24" color="#00ff00"/> <Sphere x="-10" y="0" z="0" r="3" w="26" h="24" /> <Sphere x="0" y="-10" z="0" r="3" w="26" h="24" /> <Sphere x="0" y="0" z="-10" r="3" w="26" h="24"> <texture> <TextureLoader src="textures/crate.gif" /> </texture> </Sphere> <Cube x="20" y="5" width="10" height="10" depth="10"> <texture> <TextureLoader src="textures/crate.gif" /> </texture> </Cube> <Loader src="" /> </children> </SkyBox> <fog /> </td> <LeftLabel /> <RightLabel right="25" top="10" /> </position> </desktop> 目前我正在用airoot uisys重新做一个flash,为什么选择uisys呢,因为uisys在语言写法上不会给你阻碍,思想到代码很直接,可以看下uisys做成flash IDE的效果,一下全部由uisys开发的web flash ide:可以看下里面的代码段落:1. <!-- PlayEditor.ui --> <@pub/> <head> <style> body{ margin:0px; background-color:#dddddd; } </style> </head> <@import value="jus.*"/> <desktop> <plat.TimeLine id="tl" height="230" /> <HBox> <plat.Library width="320" height="100%"></Library> <plat.Scene width="100%" height="100%"></Scene> </HBox> </desktop> <script> function init(){ } </script> 2. <!-- Scene.ui --> <@import value="jus.*"/> <style> body{ border-right:1px solid #aaaaaa; } .header{ display:flex; align-items:center; padding:0px 10px; background-color:#d0d0d0; } .frame{ background-color: #dddddd; box-shadow:0px 0px 4px rgba(0,0,0,0.2); position:relative; } .bg{ background-color:#fefefe; } </style> <VBox height="100%"> <div height="48" width="100%" class="header"> 场景&nbsp;&nbsp; <Combo> </Combo> </div> <Position width="100%" height="100%" class="frame"> <Index left="100" top="50" right="100" bottom="50"/> </Position> </VBox> airoot uisys 的可塑性非常强,对于插件的定义绝对三大框架后的大佬(我相信),来看下它为人民教育出版社开发的指数联动交互图书:我们看下其中一页的代码: <!-- 类注释 @author sunxy @version 0.0 --> <@import value="component.*" /> <@import value="root.*" /> <page> <image x="35" y="62" src="img/photo87.png" /> <image x="117" y="655" src="img/photo85.png" /> <blacktext x="126" y="66" audio="audio/page014/OtherData/231_014_01.mp3">Let's talk</blacktext> <etext x='54' y='238' audio="audio/page014/OtherData/231_014_02.mp3">Mr Jones,<br/>this is Miss Green.</etext> <etext x='356' y='252' audio="audio/page014/OtherData/231_014_03.mp3">Good morning,<br/>Miss Green.</etext> <etext x='304' y='497' audio="audio/page014/OtherData/231_014_04.mp3">Good morning.</etext> <blacktext x="71" y="594" audio="audio/page014/OtherData/231_014_06.mp3"><img src="img/photo88.png" />Draw and say</blacktext> <etext x='148' y='670' audio="audio/page014/OtherData/231_014_07.mp3">This is Miss Green.</etext> <etext x='382' y='670' audio="audio/page014/OtherData/231_014_08.mp3">This is Mr Jones.</etext> <lnum>14</lnum> </page> 上面的代码在uisys的编写框架下可以实现点击朗读,和通篇朗读,当然还可以支持游戏。 airoot uisys 先介绍这么多。

优秀的个人博客,低调大师

前端学习笔记(5) - JavaScript中this 关键字的机制

JavaScript中有几种函数 1.使用function定义的函数 function foo(){ } 2.使用箭头函数定义的函数 const foo=()=>{ } 3.在class中定义的函数 class A{ foo(){ } } 4.生成器函数 function* foo(){ } 5.class定义的类,实际上也是函数 class Foo { constructor(){ } } 6、7、8异步函数 async function foo(){ } const foo = async () => { } async function foo*(){ } 不同函数this关键字的行为 function showThis(){ console.log(this); } var o = { showThis: showThis } showThis(); // global o.showThis(); // o 普通函数的 this 值由“调用它所使用的引用”决定,其中奥秘就在于:我们获取函数的表达式,它实际上返回的并非函数本身,而是一个 Reference 类型。Reference 类型由两部分组成:一个对象和一个属性值。 不难理解 o.showThis 产生的 Reference 类型,即由对象 o 和属性“showThis”构成。 当做一些算术运算(或者其他运算时),Reference 类型会被解引用,即获取真正的值(被引用的内容)来参与运算,而类似函数调用、delete 等操作,都需要用到 Reference 类型中的对象。在这个例子中,Reference 类型中的对象被当作 this 值,传入了执行函数时的上下文当中。 调用函数时使用的引用,决定了函数执行时刻的 this 值。 const showThis = () => { console.log(this); } var o = { showThis: showThis } showThis(); // global o.showThis(); // global 我们看到,改为箭头函数后,不论用什么引用来调用它,都不影响它的 this 值。 class C { showThis() { console.log(this); } } var o = new C(); var showThis = o.showThis; showThis(); // undefined o.showThis(); // o 创建一个类并实例化以后再次调用获得的结果又是不同的 this关键字的机制 JavaScript 标准定义了 [[thisMode]] 私有属性。[[thisMode]] 私有属性有三个取值。 lexical:表示从上下文中找 this,这对应了箭头函数。 global:表示当 this 为 undefined 时,取全局对象,对应了普通函数。 strict:当严格模式时使用,this 严格按照调用时传入的值,可能为 null 或者 undefined。 class中的函数this行为与其他函数不一样正是因为class设计成了默认为strict模式执行。在strict模式下普通函数与class中的函数行为一致。 "use strict" function showThis(){ console.log(this); } var o = { showThis: showThis } showThis(); // undefined o.showThis(); // o 而箭头函数中this的指向当前上下文中的this,所以下例中foo函数内部潜逃的剪头函数this与foo相同,o.foo()中this为对象o所以内部剪头函数的this均为o。 var o = {} o.foo = function foo(){ console.log(this); return () => { console.log(this); return () => console.log(this); } } o.foo()()(); // o, o, o 操作this的内置函数 JavaScript中提供了apply call bind三个方法来改变函数中this的指向(不清楚用法自行百度)。三个方法只针对普通函数有效,箭头函数、class均不会报错,但是无法改变this,可以传参。

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册