#sort:对向量进行排序;返回排好序的内容 #order:返回排好序的内容的下标/多个排序标准 > x <- data.frame(v1=1:5,v2=c(10,7,9,6,8),v3=11:15,v4=c(1,1,2,2,1)) > sort(x$v2) [1] 6 7 8 9 10 > sort(x$v2,decreasing = TRUE) [1] 10 9 8 7 6 > order(x$v2) [1] 4 2 5 3 1 > x[order(x$v2),] v1 v
个人认为注释还是要写,算是对代码的中文翻译,因为我们的英语水平,命名习惯各不相同。
简单的说就是 get理解为查询 delete就是删除 post就是新增 put就是更新数据 四、ajax的原生写法 window.onload = function () { var oBtn { alert("失败"); } } }; } }; 五、ajax的jquery写法 () { //请求完成的处理 }, error: function () { //请求出错处理 } }); 当然,jquery还有很多简单变形的写法
async/await 让写异步代码感觉像写同步代码。async/await 并不是 ES6 的一部分,但可以通过使用 Babel 来使用它。
def use_name_get_goods_id(self, goods_name): """ 用商品名称(列表)查找商品ID :return: """ # Read a single record, if change database you need connection.commit() sql = "SELECT `id`,`name`,`ip_name`,`sales_price` FROM
Class命名为了语义化中出现多个单词,采用” - “分隔 /* 正确的写法 */ .big-title { font-weight: bold; } 用"-"隔开比使用驼峰是更加清晰。 属性名的 : 后(必须)要有空格 属性名的 : 前(禁止)加空格 一个原因是美观,其次IE 6存在一个bug, 戳bug 5.多选择器规则之间换行 当样式针对多个选择器时每个选择器占一行 /* 推荐的写法
选择元素 $('.box') // CSS3 选择器 $('.el', $parent) $().add('.el1').add('.el2') $('.box').filter(':visible') $('.box').filter(function(){ var $this = $(this) return $this.index() > 3 && $this.hasClass('xxx') }) $('.box').find('.box-header') $('.box').close
写法示例如下 <! -- 避免用 block-name–-modifier-name__element-name 的写法。改成用以下的方式。
e.printStackTrace(); } }); } } } 可以看到在finally里我们关闭流的时候要写一大堆,非常麻烦 现在推荐使用这种写法 } catch (IOException e) { e.printStackTrace(); } } } 使用try()catch{}写法
上面代码中,doThing1,doThing2,doThing3 都要返回 Promise 对象。
ajax 标准写法 $.ajax({ url:"http://www.microsoft.com", //请求的url地址 dataType:"json", //返回格式为
CSS 本身是非常强大的,但随着样式表变大,变复杂,维护 CSS 变得越来越难。这时候预处理就有用了。Sass 是一种预处理,它能让你使用一些 CSS 中没有的特性,比如:变量,嵌套(nesting),混入(mixins),继承等。这些特性能让 CSS 变的容易维护。更多描述见官网。
选取元素 document.querySelector('a') // 返回找到的第一个,不存在返回 null document.querySelectorAll('a') // 返回所有,类型是 NodeList。不存在返回长度为 0 的 NodeList 遍历元素 [].slice.call(document.querySelectorAll('a')).forEach(function(el, index){ console.log( index + ": " + el.innerHTML );
通过 Media Queries,可以给不同的设备设置不同的样式。 设备 屏幕 @media screen { } 打印机 @media print { } 屏幕尺寸 手机及更大 @media only screen and (min-width: 320px) { } 注意:(min-width: 320px) 的括号不能少。 平板及更大 @media only screen and (min-width: 768px) { } PC @media only screen and (min-wid
关于xpath路径的写法 1.选取节点 表达式 描述 nodename 选取此节点的所有子节点。 / 从根节点选取。 // 从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置。 .
本文详述JavaScript面向对象编程中的类写法,并分步骤讲述如何写出优雅的类。 一、例子 例子为一个轻提示组件Toast。 那么在原型上普通的写法如下: Toast.prototype.hide = function(){/*code*/} Toast.prototype.myValue = 1; 但是,该写法不好的地方:就是每次都要写前半部分
在一般的 update in 写法就是: update table_name set column = 'xxx' where column2 in (select x from table_name2 where xxxxxx) 但是这种写法在表数据量小的时候不会有啥问题, 但是在表的数据量比较大的情况下, 这样就会引起全表扫描, 子查询带来了巨大的资源开销,以及锁表. 优化后的写法如下: update table_a a join table_b b on a.xx=b.xx set a.xx=要变更的值 where b.xx=条件值 ---- 实际例子 第一种写法: t_form_template_struct WHERE pid = 'GE148389280359880457831') and del_flag='0' ; 分析结果为: rows : 6661 第二种写法
线 <line x1="10" x2="50" y1="110" y2="150"/> 折线 <polyline points="60 110, 65 120, 70 115, 75 130, 80 125, 85 140, 90 135, 95 150, 100 145"/> 矩形 在座标为 (10,20) 的地方画一个宽 30,高 15 的矩形。 <svg> <rect x="10" y="20" width="30" height="15"/> </svg> 背景色红色的矩形。 <svg> <
1 #include<iostream> 2 #define _ using namespace std; 3 #define __ int main() 4 #define ___ { 5 #define ____ cout<<"Hello World"; 6 #define _____ return 0; 7 #define ______ } 8 _ 9 __ 10 ___ 11 ____ 12 _____ 13 ______
浏览器相关信息 // 浏览器信息 navigator.userAgent // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36 // 运行浏览器的操作系统平台 navigator.platform // MacIntel 浏览记录历史 // 前进 history.forward() // 后退 history.bac