一直在研究ES6,JSPM和angular2一周,我找到了这个repo ES6-loader
如果我们查看底部脚本中的index.html,您会看到
System.import('reflect-metadata')
.then(function() {
return System.import('app/index');
})
.catch(console.log.bind(console));
Run Code Online (Sandbox Code Playgroud)
这是使用JSPM的systemjs polyfill来获取ES6 import.
问题: 在这种情况下,反射元数据到底是做什么的?npm reflect-meta我阅读的文档越多,我就越不了解它的作用吗?
我第一次参加E2E考试.我正在尝试消化别人的量角器测试.
问题:有很多,browser.driver.sleep这似乎很脆弱.
目标:不要使用browser.driver.sleep
问题: 什么是更好的方法browser.driver.sleep?一个不那么脆弱的东西,比如承诺或我不知道的事情大声笑?
var config = require('../../protractor.conf.js').config;
describe('this Homepage Body Tests', function(){
browser.driver.get(config.homepageUrl);
it("should open find a clinic page", function(){
// page loads :: want to fix this random wait interval
browser.driver.sleep(2000);
browser.ignoreSynchronization = true;
var string = 'clinic';
var main = '.search-large-text';
var link = element(by.cssContainingText('.submenu li a', string));
link.click().then(function() {
// page reloads :: want to fix this random wait interval
browser.driver.sleep(3000);
var title = element(by.cssContainingText(main, string));
expect(title.getText()).toBe(string);
}); …Run Code Online (Sandbox Code Playgroud) 问题: 我如何在mocha中编写一个post请求测试,测试响应是否匹配?
响应将只是一个url字符串,因为它是第三方服务的重定向.
工作示例有效负载:
curl -H "Content-Type: application/json" -X POST -d '{"participant":{"nuid":"98ASDF988SDF89SDF89989SDF9898"}}' http://localhost:9000/api/members
Run Code Online (Sandbox Code Playgroud)
member.controller.js // post方法
// Creates a new member in the DB.
exports.create = function(req, res) {
Member.findByIdAndUpdate(req.body.participant.nuid,
{ "$setOnInsert": { "_id": req.body.participant.nuid } },
{ "upsert": true },
function(err,doc) {
if (err) throw err;
res.send({
'redirectUrl': req.protocol + '://' + req.get('host') + '/registration/' + req.body.participant.nuid
})
}
);
};
Run Code Online (Sandbox Code Playgroud)
预计res.send
{"redirectUrl":"http://localhost:9000/registration/98ASDF988SDF89SDF89989SDF9898"}
Run Code Online (Sandbox Code Playgroud)
工作示例GET请求测试
var should = require('should');
var app = require('../../app');
var request = require('supertest');
describe('GET /api/members', function() …Run Code Online (Sandbox Code Playgroud) 我知道我可以删除代码和文件; 但是,有没有办法在自耕农中删除生成的路线 - 在类似的自动命令中有角度?
例如yo angular:route myroute,你是如何生成它的
我将运行哪些cmd行代码来删除,回滚或删除路径的这个脚手架?
如何将objects/dict(?)属性传播到新的object/dict中?
简单的Javascript:
const obj = {x: '2', y: '1'}
const thing = {...obj, x: '1'}
// thing = {x: '1', y: 1}
Run Code Online (Sandbox Code Playgroud)
蟒蛇:
regions = []
for doc in locations_addresses['documents']:
regions.append(
{
**doc, # this will not work
'lat': '1234',
'lng': '1234',
}
)
return json.dumps({'regions': regions, 'offices': []})
Run Code Online (Sandbox Code Playgroud) 问题:不使用any,我的onMouseMove函数的正确类型是什么?
export class Main {
private dTimer: number;
constructor() {
this.init();
}
private init() {
this.mouseHandlers();
}
private mouseHandlers() {
document.addEventListener('mousemove', this.onMouseMove)
}
private onMouseMove: EventListener = (event: MouseEvent) => {
clearTimeout(this.dTimer);
this.dTimer = setTimeout(() => {
console.log(event.pageX, event.pageY)
}, 500);
}
}
Run Code Online (Sandbox Code Playgroud)
Typescript 抱怨我的类型,我不知道如何在不使用任何类型的情况下让它开心。
main.ts(38,3): error TS2322: Type '(event: MouseEvent) => void' is not assignable to type 'EventListener'.
Types of parameters 'event' and 'evt' are incompatible.
Type 'Event' is not assignable to type 'MouseEvent'. …Run Code Online (Sandbox Code Playgroud) 我正在阅读关于HTML5Rocks上的 V8的这篇文章.这篇文章很老了,但我几乎一无所知,这让我很烦恼.我一次采取这一步,但有人可以帮助我使用阵列部分吗?
文章指出:
数组
为了处理大型和稀疏数组,内部有两种类型的数组存储:
快速元素:紧凑型密钥集的线性存储
字典元素:否则为哈希表存储
最好不要让阵列存储从一种类型转换到另一种类型.
题:
将一个什么快速元素线性存储阵列是什么样子?
将一个什么字典元素哈希表数组是什么样子?
出于预防目的,我将如何"从一种类型转换到另一种类型"?
我是全新的django和sql.我正在经历的教程def __unicode__(self)介绍了每个模型类?这里是对文档的引用但是即使在阅读之后我仍然不明白它的目的是什么?
class Project(models.Model):
name = models.CharField(max_length=300)
def __unicode__(self):
return self.name
class Task(models.Model):
description = models.CharField(max_length=300)
project = models.ForeignKey(Project)
def __unicode__(self):
return self.description
Run Code Online (Sandbox Code Playgroud) SVG很丑,请查看我的:
HTML:
<svg version="1.1" class="overlap-svg" id="alaska"></svg>
<svg version="1.1" class="overlap-svg" id="grid"></svg>
Run Code Online (Sandbox Code Playgroud)
CSS:
.overlap-svg {
position: absolute;
left:0;
top: 0;
}
Run Code Online (Sandbox Code Playgroud)
如果我们重叠这两个svgs,JS的功能是什么才能突出显示其中包含阿拉斯加(红色)部分的svg圈?
有关详细信息,请查看以下说明
我该如何改变这个:
进入这样的事情:
如果阿拉斯加(红色)的任何部分位于圆圈区域内,则圆圈应填充为红色.
请再次查看我上面的JSFiddle链接.
我需要有关如何在Angular中编写机制的指导,以便在我的应用程序中全局设置组件的"外观和感觉".请注意,我正在尝试学习@ ngrx/platform,我认为这将是一个有趣的设计约束; 但是,如果它没有意义,我愿意放手.
分解:
我有一个正在进行许多组件的应用程序.我的应用程序中的每个组件目前有3种可能的"外观(L&F)":
请注意,基于更精细的时间,可能会有一系列颜色.
这些L&F由当前用户的时间设置,例如,如果用户当前时间是早上7点,则计算的L&F将被设置为"早晨".我在一个名为ncurx/store的角度模块中跟踪这个状态,SundialModule并且gnomon是getting或者setting状态的reducers和actions的机制:
日晷/减速/ gnomon.ts:
import * as gnomon from '../actions';
export interface State {
currentHour: number,
}
const initialState: State = {
currentHour: new Date().getHours()
};
export function reducer(state = initialState,
action: gnomon.Actions) {
console.log(action, 'action');
switch(action.type) {
case gnomon.MORNING:
return {
...state,
currentHour: 6,
};
case gnomon.AFTERNOON:
return {
...state,
currentHour: 12,
};
case gnomon.EVENING:
return { …Run Code Online (Sandbox Code Playgroud) javascript ×5
angularjs ×2
python ×2
angular ×1
arrays ×1
css ×1
django ×1
ecmascript-6 ×1
ecmascript-7 ×1
global-state ×1
html ×1
jspm ×1
karma-mocha ×1
migration ×1
mocha.js ×1
mouseevent ×1
mousemove ×1
ngrx ×1
node.js ×1
npm ×1
object ×1
protractor ×1
redux ×1
selenium ×1
svg ×1
systemjs ×1
themes ×1
tsc ×1
typescript ×1
v8 ×1
yeoman ×1