jq

Swiper 滑动切换图片(可用于PC端,移动端)

回眸只為那壹抹淺笑 提交于 2020-04-18 07:28:27
作为一名后端的普通程序猿, 你让我搞这种前端不是跟我玩命吗,所以用插件来搞,省事又简单,而且Swiper使用又简单是吧; 头皮发麻,不喜欢说废话,我更喜欢直接看到效果; 按Swiper官方文档来说, 它需要配合JQuery来使用,所以也需要引入JQ; 1, 先去官网下载一波它的 CSS, JS 文件先, https://2.swiper.com.cn/download/index.html#file1   下载完直接引入即可上手用了, 路径自己改。 <link rel="stylesheet" href="css/swiper.min.css"> <script src="js/swiper.min.js"></script> 2, 废话不多说, 直接上测试例子;    HTML (swiper的写法):   container: 装所有滑动slide的容器 <!-- Swiper --> < div class ="swiper-container" > < div class ="swiper-wrapper" > < div class ="swiper-slide blue-slide" > 内容1 </ div > < div class ="swiper-slide red-slide" > 内容2 </ div > < div class ="swiper-slide

由"跨域"引出的一个终极思想(jsonp)

有些话、适合烂在心里 提交于 2020-04-18 03:41:09
1.什么是跨域? 当协议、子域名、主域名、端口号中任意一个不相同时,都算作不同域. 跨域并不是请求发不出去,请求能发出去,服务端能收到请求并正常返回结果,但是因为浏览器存在一个"同源策略",结果就被浏览器拦截了。 同源策略限制以下几种行为: Cookie、LocalStorage 和 IndexDB 无法读取 DOM和JS对象无法获得 AJAX 请求不能发送 举个例子:当一个页面中存在js或者jq的ajax请求,当该请求与当前域中的协议、子域名、主域名、端口号中任意一个不相同时,都是跨域, 最后再简单来说:浏览器具有“同源策略”,即: 因为浏览器存在一个"同源策略",浏览器只能想当前所在的域发送Ajax,如果向其他域发送请求,则浏览器就会报错。 2.处理跨域的两种方法 解决办法有两个: cors方法: 这个方法是一个主流方法,通过设置响应对象的响应头,去强制允许浏览器接受跨域的响应对象 def api (request) : ret : = HttpResponse('百度') ret["Access-Control- Allow -Origin"] = "*” #设置响应对象的响应头,接受任何跨域响应对象 return ret jsonp: 这是一种思想,不是 处理跨域问题的最好方法 ,绝对的爆炸思想 一个解决跨域的方案,是一种巧妙的机制,可以绕过浏览器的同源策略,实现跨域

Jquery消息滚动

只愿长相守 提交于 2020-04-17 13:04:14
【推荐阅读】微服务还能火多久?>>> 又是一次作业练习,jquery消息滚动,效果图如下: 源码下载及效果预览:https://www.jq22.com/jquery-info22971 代码实现起来很简单,所以看起来效果也是很不如人意,就当记录一下子趴 推荐链接 无缝滚动:http://www.jq22.com/jquery-info22981 推送滚动:http://www.jq22.com/jquery-info22468 现在来简单写一下自己的这个代码实现 js代码: $(function(){ // 滚动事件,每两秒滚动一次 var mun = setInterval(function(){ $( " li:last " ).hide( " slow " ).prependTo($( " #file0 " )).slideDown(); }, 2000 ); // 鼠标悬停事件,悬停停止滚动,鼠标移出开始滚动 $( " li " ).hover(function(){ clearInterval(mun); },function(){ mun = setInterval(function(){ $( " li:last " ).hide( " slow " ).prependTo($( " #file0 " )).slideDown(); }, 2000 ); } );

sort keys in arbitrary order

蓝咒 提交于 2020-04-16 08:34:29
问题 For a side-project I want to sort the keys of a JSON with jq, and come up with the following solution: def add_property_prefix: if .key == "beka" then "01__"+.key elif .key == "alma" then "02__"+.key elif .key == "paprika" then "03__"+.key elif .key == "korte" then "04__"+.key else .key end ; def del_property_prefix: .key | sub("^[0-9]{2}__"; "") ; to_entries | map({ key: add_property_prefix, value: .value }) | sort_by(.key) | map({ key: del_property_prefix, value: .value }) | from_entries

Convert text file with line breaks to json with jq

微笑、不失礼 提交于 2020-04-16 06:09:02
问题 I've seen a lot of examples to convert a text file to json with jq, but I get stuck on something probably obvious. My input file has this format: key1: string1 key2: string1 key1: string3 key2: string3 How can I translate that to: [ {"key1":"string1", "key2": "string2"}, {"key1":"string3", "key2": "string4"} ] I've tried to use inputs with jq, something like jq -R -n -c '[inputs|split(":")|{(.[0]):.[1]}] | add' , but it fails as soon as there's a line break in the file: jq: error (at result

Convert text file with line breaks to json with jq

醉酒当歌 提交于 2020-04-16 06:08:18
问题 I've seen a lot of examples to convert a text file to json with jq, but I get stuck on something probably obvious. My input file has this format: key1: string1 key2: string1 key1: string3 key2: string3 How can I translate that to: [ {"key1":"string1", "key2": "string2"}, {"key1":"string3", "key2": "string4"} ] I've tried to use inputs with jq, something like jq -R -n -c '[inputs|split(":")|{(.[0]):.[1]}] | add' , but it fails as soon as there's a line break in the file: jq: error (at result

Convert text file with line breaks to json with jq

大憨熊 提交于 2020-04-16 06:08:12
问题 I've seen a lot of examples to convert a text file to json with jq, but I get stuck on something probably obvious. My input file has this format: key1: string1 key2: string1 key1: string3 key2: string3 How can I translate that to: [ {"key1":"string1", "key2": "string2"}, {"key1":"string3", "key2": "string4"} ] I've tried to use inputs with jq, something like jq -R -n -c '[inputs|split(":")|{(.[0]):.[1]}] | add' , but it fails as soon as there's a line break in the file: jq: error (at result

merge two lists within a object conditionally

六眼飞鱼酱① 提交于 2020-04-16 03:05:34
问题 Hellow jq experts! I'm a jq learner and have a json obect composed lists as follows: { "image_files": [ { "id": "img_0001", "width": 32, "heigt": 32, "file_name": "img_0001.png" }, { "id": "img_0002", "width": 128, "heigt": 32, "file_name": "img_0002.png" }, { "id": "img_0003", "width": 32, "heigt": 32, "file_name": "img_0003.png" }, { "id": "img_0004", "width": 160, "heigt": 32, "file_name": "img_0004.png" } ], "annotations": [ { "id": "ann_0001", "image_id": "img_0001", "label": "A",

hhh

為{幸葍}努か 提交于 2020-04-15 07:37:20
【推荐阅读】微服务还能火多久?>>> 勿外传,收到后尽量先保存,最近百度网盘加大了和谐力度。 注:后面项目整理由于项目过多,以合集的形式呈现,如有失效,微信留言给我(资料定期更新,更新通知关注我朋友圈通知) 如有需要其他资料,也是微信给我留言(仅限技术开发类) 最容易上手的 vue2.0 链接: https://pan.baidu.com/s/1tfe4ZonryhhI_bngJcAa1A 提取码: 9fql Vue 的案例开发(入门基础案例) 链接: https://pan.baidu.com/s/1wvaEwNPNlCc2fG2cA16k-g 提取码: qw5s Vue 核心技术加实战精讲 链接: https://pan.baidu.com/s/1WJJX8fd_G5JAD_S25ecERw 提取码: s6go Vue.js 高仿饿了么 APP 开发 链接: https://pan.baidu.com/s/10BSfmGF4GvwrL1jLZoSGJw 提取码: 15ct Vue+node.js+mongodb 全栈打造商城系统(经典的 vue 全栈开发) 链接: https://pan.baidu.com/s/1u8viX-0xSVkXw7RAhBiRhg 提取码: 1eo9 开发资源工具包 链接: https://pan.baidu.com/s/1e0K

原生js判断元素是否隐藏,jq判断元素是否隐藏【转】

為{幸葍}努か 提交于 2020-04-14 16:10:40
【推荐阅读】微服务还能火多久?>>> 一.原生js判断元素是否隐藏 1.通过offsetParent判断,使用这种方法来判断当前元素是否被隐藏,包括通过设置父元素为 display:none 以及自己本身为 none 的情况。但是如果是通过设置 visibility:hidden 则无法检测出。 function isHidden(el){ return el.offsetParent === null; } 2.通过getComputedStyle方式判断 getComputedStyle使用参考 function isHidden(el){ var style = window.getComputedStyle(el); return (style.display === 'none') } 3.更简单的方式el.style.display function isHidden(el){ return (el.style.display === 'none') } 二.jq判断元素是否隐藏 1.通过.css()方法来判断,display来判断 function isHidden($el){ return $el.css('display') === 'none'; } 2.通过jq的伪类:hidden/:visible来判断 function isHidden($el){