配置:macOS High Sierra,版本10.13.2,节点:v8.1.2 npm:5.0.3当我在我的angularjs项目中运行npm start时出现此错误:
ERROR in Cannot find module 'node-sass'
Run Code Online (Sandbox Code Playgroud)
在此之后我运行:
npm i node-sass
Run Code Online (Sandbox Code Playgroud)
现在我收到这个错误:
gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
Run Code Online (Sandbox Code Playgroud)
为什么npm不会安装node-sass?我该如何安装node-sass?
当我从windows gitbash命令行:
set $HOME = c
Run Code Online (Sandbox Code Playgroud)
并做:
echo $HOME
Run Code Online (Sandbox Code Playgroud)
它没有设置它c?如何更改/设置环境变量的值?
我正在使用reactjs路由器的链接组件,我无法使onClickevent正常工作.这是代码:
<Link to={this.props.myroute} onClick='hello()'>Here</Link>
Run Code Online (Sandbox Code Playgroud)
这是通过这种方式或其他方式实现的吗?
我正在尝试对我的reactjs组件进行单元测试:
import React from 'react';
import Modal from 'react-modal';
import store from '../../../store'
import lodash from 'lodash'
export class AddToOrder extends React.Component {
constructor(props) {
super(props);
this.state = {checked: false}
//debugger
}
checkBoxChecked() {
return true
}
render() {
console.log('testing=this.props.id',this.props.id )
return (
<div className="order">
<label>
<input
id={this.props.parent}
checked={this.checkBoxChecked()}
onChange={this.addToOrder.bind(this, this.props)}
type="checkbox"/>
Add to order
</label>
</div>
)
}
}
export default AddToOrder;Run Code Online (Sandbox Code Playgroud)
刚开始我已经在努力断言checkBoxChecked方法:
import React from 'react-native';
import {shallow} from 'enzyme';
import {AddToOrder} from '../app/components/buttons/addtoorder/addtoorder';
import {expect} from 'chai'; …Run Code Online (Sandbox Code Playgroud)我在Prettier 1.7.2和Eslint 1.7.0中使用vscode。每换行后,我得到:
[eslint] Delete 'cr' [prettier/prettier]
Run Code Online (Sandbox Code Playgroud)
这是.eslintrc.json:
{
"extends": ["airbnb", "plugin:prettier/recommended"],
"env": {
"jest": true,
"browser": true
},
"rules": {
"import/no-extraneous-dependencies": "off",
"import/prefer-default-export": "off",
"no-confusing-arrow": "off",
"linebreak-style": "off",
"arrow-parens": ["error", "as-needed"],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore"
}
],
"no-plusplus": "off"
},
"parser": "babel-eslint",
"plugins": ["react"],
"globals": {
"browser": true,
"$": true,
"before": true,
"document": true
}
}
Run Code Online (Sandbox Code Playgroud)
.prettierrc
{
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": …Run Code Online (Sandbox Code Playgroud) 我是reactjs/redux的初学者,找不到一个简单易用的如何使用api调用来检索redux应用程序中的数据的示例.我想你可以使用jquery ajax调用,但有可能有更好的选择吗?
我将一个名为Auth.js的.js文件(因此不是.ts文件)导入到reactjs和typescript应用程序中,所以在我的组件中我有这个:
import * as Auth from '../Auth/Auth';
..
const auth = new Auth();
Run Code Online (Sandbox Code Playgroud)
这是我的Auth.js的一部分:
export default class Auth {
auth0 = new auth0.WebAuth({
domain: AUTH_CONFIG.domain,
clientID: AUTH_CONFIG.clientId,
redirectUri: AUTH_CONFIG.callbackUrl,
audience: `https://${AUTH_CONFIG.domain}/userinfo`,
responseType: 'token id_token',
scope: 'openid'
});
constructor() {
this.login = this.login.bind(this);
this.logout = this.logout.bind(this);
this.handleAuthentication = this.handleAuthentication.bind(this);
this.isAuthenticated = this.isAuthenticated.bind(this);
}
..
Run Code Online (Sandbox Code Playgroud)
当我运行webpack时,我收到以下错误消息:
ERROR in ./src/containers/main.tsx
(16,14): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature.
Run Code Online (Sandbox Code Playgroud)
如何解决此TS错误?
我在reactjs/redux中使用这个reducer构建了一个购物车应用程序:
const initialState = {
items: [],
cartOpen: false,
total: 0
}
const Cart = (state = initialState, action) => {
switch (action.type) {
case 'ADD_TO_CART':
let newstate = [...state, action.payload];
var newTotal = 0;
newstate.forEach(it => {
newTotal += it.item.price;
});
newstate.total = newTotal;
newstate.cartOpen =true
return newstate;
case 'TOGGLE_CART':
debugger;
return !state.cartOpen;
default:
return state
}
}
export default Cart;
Run Code Online (Sandbox Code Playgroud)
我试图设置购物车的状态即打开,但是当我检查日志时,购物车属性是否更新而不是cartOpen属性?
我想在我的angular 2应用程序中安装@ ngrx/store模块.我正在使用npm install并收到以下错误:
npm ERR! peerinvalid The package rxjs@5.0.0-beta.6 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/core@2.0.0-rc.0 wants rxjs@5.0.0-beta.6
npm ERR! peerinvalid Peer @angular/http@2.0.0-rc.0 wants rxjs@5.0.0-beta.6
npm ERR! peerinvalid Peer angular2@2.0.0-beta.16 wants rxjs@5.0.0-beta.2
npm ERR! peerinvalid Peer @ngrx/store@1.5.0 wants rxjs@5.0.0-beta.6
Run Code Online (Sandbox Code Playgroud)
这是否意味着我必须升级我的angular2模块,因为它需要更低版本的rxjs@5.0.0-beta.2?
我正在使用夜视来测试我的应用程序.其中一个测试失败,因为它无法滚动到我怀疑它正在测试的元素.问题我需要滚动还是有其他方法可以做到?这是我正在测试的元素:
return this.waitForElementVisible('#myElement', 4000) //wait for it to be visible
.assert.visible('#myElement')
.click('#myElement')
Run Code Online (Sandbox Code Playgroud)
该元素位于页面的顶部,但testrunner在页面上向下滚动了一下,并且在屏幕截图中不可见.如果需要滚动到此元素,我该怎么办?或:我如何测试这个元素?
reactjs ×6
react-redux ×3
javascript ×2
npm ×2
angular ×1
angularjs ×1
chai ×1
enzyme ×1
eslintrc ×1
git ×1
git-bash ×1
ngrx ×1
node.js ×1
prettier ×1
react-router ×1
typescript ×1
unit-testing ×1