简体   繁体   English

添加JavaScript和CSS文件来反应

[英]adding javascript and css files to react

I'm integrating d3-timeseries graph with react. 我正在将d3时间序列图与react集成在一起。

So, this graph uses 3 files of its own 2 javascript files and one css file. 因此,此图使用了3个文件,其中有2个JavaScript文件和1个CSS文件。

files are available here : https://github.com/mcaule/d3-timeseries/tree/master/src 文件位于此处: https : //github.com/mcaule/d3-timeseries/tree/master/src

another file is : 另一个文件是:

<script src="https://d3js.org/d3.v3.min.js"></script>

In my react app, how should refer all these d3 javascript and css files? 在我的React应用程序中,应如何引用所有这些d3 javascript和CSS文件? So, far I just included tags for all these files in my html. 因此,到目前为止,我只在html中包括了所有这些文件的标签。 How to do it in react? 如何做出反应?

Also, d3-timeseries javascript code i should put in some file or refer only using . 另外,我应该将d3-timeseries javascript代码放入某个文件中,或者仅使用引用。 Please suggest, I'm new to react. 请提出建议,我是新来的人。 Thanks. 谢谢。

use import 使用import

import React from 'react';
import d3Js from 'https://d3js.org/d3.v3.min.js';
import 'path/to/your/file.css';

export default class MyNavbar extends React.Component {
    render(){
      return (
       <div> something </div>
      );
    }
}

Because the rendering of d3 and React differ in their concepts, its quite hard to integrate d3 inside React. 由于d3和React的渲染概念不同,因此很难将d3集成到React中。

Its maybe better to use the React-Way D3 which provides this package: http://www.reactd3.org 最好使用提供此软件包的React-Way D3: http : //www.reactd3.org

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM