简体   繁体   English

在index.html中声明js库只需在reactjs中加载1次

[英]Declaring js libraries in index.html just load 1 time in reactjs

I have a problem and hope people suggest me some solutions. 我有一个问题,希望有人建议我一些解决方案。 I am using Reactjs that has some js (jquery) libraries declared in index.html and all functions only run if I refresh the page. 我正在使用Reactjs,它在index.html中声明了一些js(jquery)库,并且所有功能只有在刷新页面后才能运行。 Now I want when I change the route, the functions in the js library will run again. 现在,我想要更改路线时,js库中的功能将再次运行。 I tried to use $ from 'jquery' in my container to call tge libraries really hard to export because it has many errors. 我试图在容器中使用来自'jquery'的$来调用tge库,因为它有很多错误,真的很难导出。 Thank you. 谢谢。

The index file only gets loaded on page load in react. 索引文件仅在react中的页面加载时加载。 If you want something to be called when routes get changed you need to configure that through the router you are using. 如果要在路由更改时调用某个名称,则需要通过使用的路由器进行配置。 If you are using react-router then you can use history.listen() documentation here . 如果您使用react-router,则可以在此处使用history.listen() 文档

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

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