小编Den*_*lka的帖子

React 组件继承

基础组件

import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { addToCart, removeFromCart, changeQuantity } from '../../actions/CartActions';

@connect(null, { addToCart, removeFromCart, changeQuantity })
class Product extends Component {
  constructor() {
    super();
    this.addToCart = this.addToCart.bind(this);
  }
  addToCart() {
    this.props.addToCart(this.props.product);
  }
  removeFromCart() {

    this.props.removeFromCart(this.props.product);
  }
  changeProductQuantity() {

    this.props.changeQuantity(this.props.product);
  }
  render() {
    return (
      <div className="product_box">
        <h3>{this.props.product.title}</h3>
        <Link to={`details/${this.props.product._id}`}>
          <img src={this.props.product.image_url} alt={this.props.product.title} />
        </Link>
        <p>{this.props.product.description}</p>
        <p className="product_price">{this.props.product.price} {this.props.product.currency}</p>
        <Link onClick={this.addToCart} className="addtocart" …
Run Code Online (Sandbox Code Playgroud)

javascript oop reactjs redux react-redux

5
推荐指数
1
解决办法
2万
查看次数

未捕获TypeError:useValue,useFactory,数据不可迭代!Angular 4 cli项目错误

我是Angular 4的新手,我刚刚通过Angular Cli创建了一个项目,我得到了错误

Uncaught TypeError: useValue,useFactory,data is not iterable! 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我无法解决它.我安装并重新安装了cli,我只是想知道如何解决它.我所做的只是

ng new myprj 
 mkdir myprj 
 ng serve
Run Code Online (Sandbox Code Playgroud)

node.js phantomjs casperjs karma-runner angular

5
推荐指数
1
解决办法
2121
查看次数