目前使用了:
//假设你获得了这么一段数据
var data = {
title: '前端圈',
intro: '一群码js的骚年,幻想改变世界,却被世界改变。',
list: [
{name: 'bob', city: '杭州'}, {name: 'peter', city: '北京'},
{name: 'faker', city: '杭州'}, {name: 'joking', city: '北京'}
]
};
var tpl = document.getElementById('tpl').innerHTML; //读取模版
//方式一:异步渲染(推荐)
laytpl(tpl).render(data, function(render){
document.getElementById('view').innerHTML = render;
});
//方式二:同步渲染:
var render = laytpl(tpl).render(data);
document.getElementById('view').innerHTML = render;复制代码
<h3>{{ d.title }}</h3>
<p class="intro">{{ d.intro }}</p>
<ul>
{{# for(var i = 0, len = d.list.length; i < len; i++){ }}
<li>
<span>{{ d.list[i].name }}</span>
<span>所在城市:{{ d.list[i].city }}</span>
</li>
{{# } }}
</ul>复制代码
https://www.layui.com/复制代码
location.search
css
search 属性是一个可读可写的字符串,可设置或返回当前 URL 的查询部分
(问号 ? 以后的部分)
处理移动端 click
事件 300 毫秒延迟, 由 FT Labs 开发,前端
Github 项目地址:github.com/ftlabs/fast… 。jquery
根据 Google 开发者文档:git
...mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.github
从点击屏幕上的元素到触发元素的 click
事件,移动浏览器会有大约 300 毫秒的等待时间。为何这么设计呢? 由于它想看看你是否是要进行双击(double tap)操做。bootstrap
width=device-width
, Android 上的 Chrome 32+ 会禁用 300ms 延时;<meta name="viewport" content="width=device-width, initial-scale=1">
复制代码
user-scalable=no
,Android 上的 Chrome(全部版本)都会禁用 300ms 延迟。-ms-touch-action: none
禁止元素双击缩放(参考文章)。TODO: 修改使用接口浏览器
window.addEventListener('load', function() {
FastClick.attach(document.body);
}, false);复制代码
$(function() {
FastClick.attach(document.body);
});复制代码
var attachFastClick = require('fastclick');
attachFastClick(document.body);复制代码