我正在尝试设置一个 React 开发环境,我收到的一条指令是在终端中输入我的目录并输入以下代码:
\n\ntouch .gitignore\nRun Code Online (Sandbox Code Playgroud)\n\n当我创建一个带有名称和扩展名(例如 )的文件时, touch 命令工作正常,index.html但由于这似乎只是一个扩展名,所以什么也没有发生。
显然这是一个关于上传到 GitHub 的重要文件 - 有人可以帮忙吗?
\n\n更新:我创建了x.gitignore,然后尝试删除x,OSX 会弹出一个对话框:
You can\xe2\x80\x99t use a name that begins with a dot \xe2\x80\x9c.\xe2\x80\x9d, because these names are reserved for the system. Please choose another name.\nRun Code Online (Sandbox Code Playgroud)\n 我应该首先说我对Heroku来说是全新的,而且现在对我来说都很陌生.
无论如何,我已经完成了Heroku入门教程,上传了一个克隆git repo,这很好用.
我现在正试图用我自己的一些代码完成这个,但是很挣扎.
heroku create.这很成功.git push heroku master按照教程中的说明运行,并收到以下错误:error: src refspec master does not match any.
error: failed to push some refs to 'heroku'
如果有人能解释我在这里缺少的东西,我将不胜感激?提前致谢.
两个选项,哪个更好,为什么:
例A.
文件1 Users.js::
angular.module('users', []);
Run Code Online (Sandbox Code Playgroud)
文件2 userService.js::
angular.module('users').service('userService', ['$q', UserService]);
function UserService($q) {
var users = [
{
name: 'Bob Smith',
age: 26,
address: 'London',
},
{
name: 'John Simpson',
age: 41,
address: 'New York',
},
{
name: 'Maria West',
age: 36,
address: 'Chicago',
}
];
// Promise-based API
return {
loadAllUsers : function() {
// Simulate async nature of real remote calls
return $q.when(users);
}
};
}
})();
Run Code Online (Sandbox Code Playgroud)
文件3 UserController.js::
angular.module('users').controller('UserController', ['$scope', …Run Code Online (Sandbox Code Playgroud) 我是 React 的新手,不确定如何执行此操作。
我有一组对象,这些对象已映射并在我的视图中呈现。我想要做的是设置一个表单,将每个字段的值提交给新对象的相应属性,但我不确定如何执行此操作。
这是我在视图中呈现的初始数据:
contactArray = [
{
name: 'John'
email: 'john@email.com'
number: 111-111-111
},
{
name: 'Dave'
email: 'dave@email.com'
phone: '222-222-222'
}
]
Run Code Online (Sandbox Code Playgroud)
然后我有一个表格:
class InputForm extends Component {
render() {
return (
<form>
<input type='text' onChange={this.handleChange}/>
<input type='text' onChange={this.handleChange}/>
<input type='text' onChange={this.handleChange}/>
<button type='submit' onSubmit={this.handleSubmit}>SUBMIT</button>
</form>
)
}
Run Code Online (Sandbox Code Playgroud)
然后我假设我将状态声明为:
constructor(props) {
super(props);
this.state = {
name: '',
email: '',
phone: ''
}
}
Run Code Online (Sandbox Code Playgroud)
然后提交功能我真的不知道怎么处理...
handleSubmit() {
// not sure about this...
this.setState({
name: // ????
email: // …Run Code Online (Sandbox Code Playgroud) 关于.splice()方法的基本问题,以及如何最好地从数组中删除元素.
我想从数组中删除一个项目,.splice()但是当我这样做时,我希望原始数组减去已删除的元素..splice()返回已删除的元素.
var arr = [1, 2, 3, 4, 5, 6, 7]
var newArr = arr.splice(3, 1)
console.log(newArr) // [4]
// whereas I want [1, 2, 3, 5, 6, 7]
Run Code Online (Sandbox Code Playgroud)
什么是最好,最有说服力的方法呢?
我已经看到了节点快速服务器的以下设置:
server.js
import { Server } from 'http';
import Express from 'express';
const app = new Express();
const server = new Server(app);
Run Code Online (Sandbox Code Playgroud)
既然可以直接运行express,那么将express服务器作为http服务器的参数返回有什么好处呢?
我在尝试让我的reducer在Redux中正常工作时遇到了问题.我是Redux的新手,所以我可能会错过一些简单的东西,但是我已经玩了一段时间并且无法弄清楚出了什么问题.
这是我的过程:
首先,我定义了我需要的索引值.记录时,返回正确的数字......
const thisCommentIndex = parseInt(comments.indexOf(comment))
Run Code Online (Sandbox Code Playgroud)
<div onClick={this.props.removeComment.bind(null, thisCommentIndex)}></div>
Run Code Online (Sandbox Code Playgroud)
export function removeComment(index) {
return {
type: 'REMOVE_COMMENT',
index
}
}
Run Code Online (Sandbox Code Playgroud)
function comments(state = [], action) {
switch(action.type) {
case 'REMOVE_COMMENT' :
console.log('removing comment with index of ' + action.index)
return [
...state.slice(0, action.index), // why isn't this working???
...state.slice(action.index)
]
default :
return state
}
return state;
}
Run Code Online (Sandbox Code Playgroud)
当我console.log('removing COMMENT with index of ' + action.index),它正确记录action.index,我期望的整数.但该函数不会按预期删除元素.
奇怪的是,如果我只是简单地传递数组索引,它工作正常(删除数组元素).(我会这样做,但由于我设置我的应用程序的方式,在这种情况下它将无法工作).
我在这里错过了什么吗?任何帮助赞赏.
我正在尝试将我的文件推送到GitHub上的repo,我收到一个错误.谁能帮助解释我做错了什么?
正在抛出一条错误消息,但我无法理解它(我是Git的新手......)
git push -u origin master
> To https://github.com/URL ! [rejected] master -> master (fetch
> first) error: failed to push some refs to 'https://URL' hint: Updates
> were rejected because the remote contains work that you do hint: not
> have locally. This is usually caused by another repository pushing
> hint: to the same ref. You may want to first integrate the remote
> changes hint: (e.g., 'git pull ...') before pushing again. hint: See
> the …Run Code Online (Sandbox Code Playgroud)