让我们从一些事件监听器开始:
window.addEventListener('scroll', function (e) {
console.log('scroll', e);
});
window.addEventListener('touchstart', function (e) {
console.log('touchstart', e);
});
window.addEventListener('touchmove', function (e) {
console.log('touchmove', e);
});
window.addEventListener('touchend', function (e) {
console.log('touchend', e);
});
Run Code Online (Sandbox Code Playgroud)
我需要以编程方式触摸文档的位置{pageX: 0, pageY: 0},移动它{pageX: 0, pageY: 100}并结束触摸事件.
为此,我将构建一个辅助函数TouchEvent,它将触发指定元素上的触摸事件.
/**
* @see https://gist.github.com/sstephenson/448808
* @see https://developer.apple.com/library/iad/documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.html
* @see http://stackoverflow.com/questions/18059860/manually-trigger-touch-event
*/
function touchEvent (element, type, identifier, pageX, pageY) {
var e,
touch,
touches,
targetTouches,
changedTouches;
touch = document.createTouch(window, element, identifier, pageX, pageY, pageX, pageY);
if (type == …Run Code Online (Sandbox Code Playgroud) 我一直在努力学习角度.我有一个测试项目,我按照本教程设置:
http://shmck.com/webpack-angular-part-1/
我一直在尝试增加它来使用html-loader来解析我的html文件,并在编译后用require替换我的img标签上的src.没运气.我可以让scss加载器将图像的上下文更改为它.我还可以要求控制器中的图像供我查看.但是,如果我只是将img标签的src属性与相对url一起保留,它什么都不做.
这是webpack.config中的我的加载器:
loaders:
[
{
test: /\.scss$/,
loader: 'style!css!sass'
},
{
test: /\.js$/,
loader: 'ng-annotate!babel!jshint',
exclude: /node_modules|bower_components/
},
{
test: /\.html$/,
loader: "html-loader"
},
{
test: /\.json/,
loader: 'json'
},
//not sure if this is still needed
{
test: /\.jpe?g$|\.gif$|\.png$/i, loader: "url-loader"
}
]
Run Code Online (Sandbox Code Playgroud)
这是我的低html img标签:
<img src="./darthvader.jpg">
Run Code Online (Sandbox Code Playgroud)
尝试重构具有大量内联img标记的现有站点并将其用作测试.
/**
* @param {String} foo
* @param {Number} bar
*/
Run Code Online (Sandbox Code Playgroud)
要么
/**
* @param {string} foo
* @param {number} bar
*/
Run Code Online (Sandbox Code Playgroud)
JSDoc @type文档没有明确说明.
我总是大写String,Number因为我的理解是我需要使用构造函数名称.在JavaScript中,String并Number作为构造函数存在.
我注意到不一致:我定义等基本类型(例如null,undefined)为小写.
原始类型名称需要是大写还是小写?
我有一个babel-preset-es2015-webpack依赖的package()babel-preset-es2015.babel-preset-es2015有依赖性babel-plugin-transform-es2015-modules-commonjs.
我如何要求babel-plugin-transform-es2015-modules-commonjs确保它与我的babel-present-es2015依赖项所使用的包相同?
简单地做:
require('babel-plugin-transform-es2015-modules-commonjs');
Run Code Online (Sandbox Code Playgroud)
将在NPM3设置中工作(假设没有其他依赖项需要不同版本babel-plugin-transform-es2015-modules-commonjs),但在NPM2中不起作用.
我在AWS上使用CoreOS创建了一个Kubernetes集群,但我无法与主节点进行通信.
例如,类似于以下操作的操作类似于kubectl exec或kubectl logs失败:
Error from server: dial tcp: lookup ip-XXX-X-XXX-XXX.eu-west-1.compute.internal: no such host
Run Code Online (Sandbox Code Playgroud)
我在Github上发现了一些描述问题的问题所以我知道团队知道这个bug,但是我想在这里询问是否有可能使用一些解决方法,直到它以某种方式得到解决.
提到的一个解决方法是使用--hostname-override标志,但是当我在AWS上时,这个标志被忽略(参见#22984)
鳄鱼可能不是正确的词; 我欢迎对标题进行更正.
我希望容器能够像下图中那样有鳄鱼边框.

如果所讨论的元素具有可靠的背景,则border-image可以使用伪元素欺骗或CSS3 .然而,在这种情况下,容器的内容是非重复图案.
或者,图像本身可以具有边界.但是,由于图像扩展的方式(用于显示图像的动画),这是不可能的.
我能想到的唯一选择是SVG.
import utilityRemove from 'lodash/array/remove';
import utilityAssign from 'lodash/object/assign';
import utilityRandom from 'lodash/number/random';
import utilityFind from 'lodash/collection/find';
import utilityWhere from 'lodash/collection/where';
let util;
util = {};
util.remove = utilityRemove;
util.assign = utilityAssign;
util.random = utilityRandom;
util.find = utilityFind;
util.where = utilityWhere;
Run Code Online (Sandbox Code Playgroud)
使用ES6模块系统有更好的方法吗?
如何强制babel不要查看父目录.babelrc?
.babelrc文件:./a/.babelrc和./a/example/.babelrc.babel在./a/example路上奔跑../a/.babelrc 定义了一个插件"lodash"../a/example我试过设置./a/example/.babelrc为:
{
"stage": 0,
"plugins": []
}
Run Code Online (Sandbox Code Playgroud)
但是,babel在./a/example路径中运行仍然使用"lodash"插件.
$ pwd
/a/example
$ cat ./.babelrc
{
"stage": 0,
"plugins": []
}
$ cat ./../.babelrc
{
"stage": 0,
"plugins": [
"lodash"
]
}
$ babel ./src/
Error: ENOENT: no such file or directory, scandir '/a/node_modules/babel-plugin-lodash/node_modules/lodash'
[..]
$ babel --babelrc ./.babelrc ./src/
Error: ENOENT: no such file or …Run Code Online (Sandbox Code Playgroud) 一个非常简单的程序,打印3行输出:
console.log('a');
console.log('b');
console.log('c');
Run Code Online (Sandbox Code Playgroud)
程序是否有一种方法可以在打印后删除最后一行?
console.log('a');
console.log('b');
console.log('c');
eraseLastLine();
console.log('C');
Run Code Online (Sandbox Code Playgroud)
会产生:
a
b
C
Run Code Online (Sandbox Code Playgroud)