我一直在寻找一些.babelrc
从转换代码中删除评论的选项,但我没有运气.我试过这个:
{
"comments": false
}
Run Code Online (Sandbox Code Playgroud)
以及
{
"options": {
"comments": false
}
}
Run Code Online (Sandbox Code Playgroud)
并且都不起作用.我没有想法,我无法在任何地方找到任何体面的文档.
我希望从.js
文件中公开一个函数,在该函数中我更愿意访问商店中的变量.
代码片段: -
import { connect } from 'react-redux';
function log(logMessage) {
const {environment} = this.props;
console.debug('environment' + environment + logMessage );
....
}
function mapStateToProps(state) {
return {
environment : state.authReducer.environment
};
}
export default function connect(mapStateToProps)(log);
Run Code Online (Sandbox Code Playgroud)
我有很多组件,通过附加类connect
,我可以附加功能connect()
吗?
有
var obj = { a: 1, b: 2};
Run Code Online (Sandbox Code Playgroud)
有什么区别
obj = Object.assign(obj, { c: 3});
Run Code Online (Sandbox Code Playgroud)
和
obj = {...obj, c: 3 };
Run Code Online (Sandbox Code Playgroud) 嗨,大家好,我希望你能帮助我,
如果我想运行我的应用程序,我会收到此错误.
错误:任务':app:transformClassesWithInstantRunForDebug'的执行失败.java.lang.NullPointerException(无错误消息)
我的Gradle看起来像这样
pply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.example.herold.datenaufnahme"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile project(':EMDK')
}
Run Code Online (Sandbox Code Playgroud) 我正在关注有关CloudKit的WWDC会议.在这里,有这个代码剪断:
let changesOperation = CKFetchDatabaseChangesOperation(previousServerChangeToken: privateDatabaseChangeToken)
//(...)
changesOperation.fetchDatabaseChangesCompletionBlock = {
(newToken: CKServerChangeToken?, more: Bool, error: NSError?) -> Void in
// error handling here
self.sharedDBChangeToken = newToken // cache new token
self.fetchZoneChanges(callback) // using CKFetchRecordZoneChangesOperation
}
Run Code Online (Sandbox Code Playgroud)
即使代码完全是从幻灯片中复制的,XCode也会出现这个错误:
无法分配类型'(CKServerChangeToken?,Bool,NSError?) - > Void'的类型'((CKServerChangeToken?,Bool,错误?) - > Void)?'
我正在使用XCode 8.0 Beta 4,目标是iOS 10,以防这应该是编译器错误.
我有这个简单的代码:
module Matrix where
matrix :: a -> (Int, Int) -> [[a]]
matrix x (width, height) = replicate height (replicate width x)
mapMatrix :: (a -> b) -> [[a]] -> [[b]]
mapMatrix f m = map (map f) m
Run Code Online (Sandbox Code Playgroud)
当我做:
mapMatrix (+1) (matrix 0 (2,2))
Run Code Online (Sandbox Code Playgroud)
我得到了,如预期的那样:
[[1,1],[1,1]]
可能我误解了monad和/或>>=
运算符,但我希望以下内容具有相同的输出:
matrix 0 (2,2) >>= mapMatrix (+1)
Run Code Online (Sandbox Code Playgroud)
相反,我得到:
约束中的非类型变量参数:Num [b](使用FlexibleContexts允许此操作)当检查推断类型It :: forall b时.(Num [b],Num b)=> [[b]]
我怎么能用mapMatrix (+1) (matrix 0 (2,2))
monad 写,所以我可以从左到右读取和编写代码而不是从内到外,因为你可以想象,我打算在mapMatrix
同一个矩阵上使用很多东西,比如:
matrix ... >>= mapMatrix ... …
Run Code Online (Sandbox Code Playgroud) 我是React和Redux的新手,仍然有点困惑。
我的目标是使用GET请求在HTML中呈现一堆json数据。我正在使用react和redux来管理对象的状态,但是我相信我的问题是数据甚至不存在
因此,基本上,每当有人请求URL / courses时,他/她都将在json中看到大量数据。
我在组件中收到错误
TypeError:无法读取未定义的属性“ map”
这是代码
行动
export function getCourses() {
return (dispatch) => {
return fetch('/courses', {
method: 'get',
headers: { 'Content-Type', 'application/json' },
}).then((response) => {
if (response.ok) {
return response.json().then((json) => {
dispatch({
type: 'GET_COURSES',
courses: json.courses
});
})
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
减速器
export default function course(state={}, action) {
switch (action.type) {
case 'GET_COURSES':
return Object.assign({}, state, {
courses: action.courses
})
default:
return state;
}
}
Run Code Online (Sandbox Code Playgroud)
零件
import React from 'react';
import { …
Run Code Online (Sandbox Code Playgroud) 鉴于以下代码,我将如何绑定单击我选择的选项selectedOption.name
和selectedOption.value
?
app.component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
options = [
{
name: 'test1',
value: "This is test1's value"
},
{
name: 'test2',
value: "This is test2's value"
},
{
name: 'test3',
value: "This is test3's value"
}
]
}
Run Code Online (Sandbox Code Playgroud)
app.component.html:
<button md-icon-button [md-menu-trigger-for]="menu">
<md-icon>comment</md-icon>
</button>
<md-menu #menu="mdMenu">
<div *ngFor="let option of options">
<button md-menu-item>{{option.name}}</button>
</div>
</md-menu>
<h3>Your selected option: </h3>
<p>{{selectedOption.name}}: {{selectedOption.value}}</p>
Run Code Online (Sandbox Code Playgroud) 让我们从以下分类开始
public abstract class Automobile { }
public class Automobile<T> : Automobile where T : Automobile { }
public class Car : Automobile<Car> { }
public class Truck : Automobile<Truck> { }
public class SmartAutomobile<T> : Automobile<T>
{
public T MyAutomobile { get; set; }
public SmartAutomobile(SmartTechnology smart)
{
// Cannot implicitly convert Automobile to T
this.MyAutomobile = AutomobileFromSmart(typeof(T), smart);
}
public static Automobile AutomobileFromSmart(Type type, SmartTechnology smart)
{
if (type == typeof(Car))
return new Car { /* ... */ …
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习 LINQ 并从 MSD 文档中发现SkipWhile
,只要语句为真,就会倾向于跳过该值。然而,当我在下面使用这个语句时,我没有得到预期的结果。
int[] numbers = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
var allButFirst3Numbers = numbers.SkipWhile(x => x > 9);
foreach (var n in allButFirst3Numbers)
{
Console.WriteLine(n);
}
Run Code Online (Sandbox Code Playgroud)
从上面的代码结果应该是
1、2、3、4、5、6、7、8、9
但我得到的结果是
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
谁能指出我在这方面做错了什么,以及如何获得预期的结果。
我想将一个字符串序号转换为我搜索过的perl中的数字,但是没有得到确切的答案.
示例:如果输入是
one it should be 1.
five hundred it should be 500.
three hundred it should be 300.
Run Code Online (Sandbox Code Playgroud)
有没有任何模块可以做到这一点?
javascript ×4
c# ×2
reactjs ×2
redux ×2
android ×1
angular ×1
babeljs ×1
cloudkit ×1
ecmascript-6 ×1
haskell ×1
ios ×1
java ×1
linq ×1
monads ×1
perl ×1
perl-module ×1
react-redux ×1
swift3 ×1
xcode ×1