在我的NodeJSv4.1.1代码中使用Babel.
得到了需要挂钩:
require("babel-core/register");
$appRoot = __dirname;
module.exports = require("./lib/controllers/app");
Run Code Online (Sandbox Code Playgroud)
在随后的lodaded .js文件中,我正在做:
import { Strategy as LocalStrategy } from "passport-local";
Run Code Online (Sandbox Code Playgroud)
但是,这会在CLI中生成以下错误:
import { Strategy as LocalStrategy } from "passport-local";
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at loader (/Users/*/Documents/Web/*/node_modules/babel-core/node_modules/babel-register/lib/node.js:128:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/*/Documents/Web/*/node_modules/babel-core/node_modules/babel-register/lib/node.js:138:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at module.exports (index.js:9:5)
at Object.<anonymous> (app.js:102:39)
Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的网站托管Google Material Design图标集但是我无法在Chrome或Safari中显示图标.
我正在使用这个CSS文件:
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(/public/dist/font/Material-Design-Icons.eot); /* For IE6-8 */
src: url(/public/dist/font/Material-Design-Icons.woff2) format('woff2'),
url(/public/dist/font/Material-Design-Icons.woff) format('woff'),
url(/public/dist/font/Material-Design-Icons.ttf) format('truetype');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
width: 1em;
height: 1em;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* …Run Code Online (Sandbox Code Playgroud) 我有一个需要去抖动的字段的onchange事件,我正在使用下划线,但是当我使用debouncer时,传递给React处理程序的事件似乎已过时.
<div className='input-field'>
<input onChange={_.debounce(this.uriChangeHandler.bind(this), 500)} id='source_uri' type='text' name='source_uri' autofocus required />
<label htmlFor='source_uri'>Website Link</label>
</div>
uriChangeHandler(event) {
event.preventDefault();
let uriField = $(event.target);
let uri = uriField.val();
this.setState({
itemCreateError: null,
loading: true
});
this.loadUriMetaData(uri, uriField);
}
Run Code Online (Sandbox Code Playgroud)
我收到这个错误: Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're calling preventDefault on a released/nullified synthetic event. This is a no-op. See https://fb.me/react-event-pooling for more information.
使用onchange w/o debouncer工作正常.
javascript javascript-events underscore.js debouncing reactjs
我有一个服务工作者为我的网站,但我不知道如何在出现网络错误时处理它,我查看了Mozilla的指南,但是当我离线运行工作程序时,它说网络错误已通过对respondWith函数而言,catch承诺似乎没有响应缓存数据.
this.addEventListener('install', function(event) {
event.waitUntil(
caches.open('v1').then(function(cache) {
return cache.addAll([
'/',
'/favicon.ico',
'/f3be2e30f119a1a9b0fdee9fc1f477a9',
'/index.html',
'/sw.js'
]);
})
);
});
this.addEventListener('fetch', function(event) {
var response;
event.respondWith(caches.match(event.request).catch(function() {
return fetch(event.request);
})).then(function(r) {
response = r;
caches.open('v1').then(function(cache) {
cache.put(event.request, response);
});
return response.clone();
}).catch(function(event) {
console.log(event, 'borken');
return caches.match(event.request);
});
});
Run Code Online (Sandbox Code Playgroud)
这是我的任务:编写一个函数:
onlyDigits :: String -> String
Run Code Online (Sandbox Code Playgroud)
从字符串中去除所有非数字字符(例如,onlyDigits“ ac245d62”为“ 24562”)。
我有这个:
onlyDigits :: String -> String
onlyDigits a = [ (not)isAlpha b | b <- a ]
Run Code Online (Sandbox Code Playgroud)
但我不能编译它
谁能看到我哪里出问题了?
javascript ×3
babeljs ×1
css ×1
debouncing ×1
ecmascript-6 ×1
haskell ×1
icons ×1
node.js ×1
reactjs ×1