javascript Fetch1.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Fetch1.js相关的知识,希望对你有一定的参考价值。

import React, { Component } from 'react';
import Fetch from 'react-fetch-component';

import fetchMock from 'fetch-mock';

export default class Basic extends Component {
  render() {
    return (
      <div>
        <h1>Basic</h1>
        <Fetch url="https://example.com">
          {({ loading, data, error }) => (
            <div>
              {loading && <span>Loading...</span>}
              {data && data.map((d, i) => <div key={i}>{d.last}</div>)}
            </div>
          )}
        </Fetch>
      </div>
    );
  }

  /* Setup consistent fetch responses */
  componentWillMount() {
    var data = [{ name: 'aysha' }];
    var bitstamp = [
      {
        high: "19666.00",
        last: "18947.62",
        timestamp: "1513582584",
        bid: "18890.24",
        vwap: "18834.59",
        volume: "13167.18846628",
        low: "17835.20",
        ask: "18948.98",
        open: 18953
      }
    ]

    fetchMock.get('https://example.com', bitstamp);
  }

  componentWillUnmount() {
    fetchMock.restore();
  }
}

以上是关于javascript Fetch1.js的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript介绍

javascript的题。

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法