简体   繁体   English

在React环境中使用jQuery插件

[英]Using jQuery plugin in react environment

I'm using semantic react but looking for date picker, I came across this library. 我正在使用语义反应,但是在寻找日期选择器时,我遇到了这个库。 https://github.com/mdehoog/Semantic-UI-Calendar https://github.com/mdehoog/Semantic-UI-Calendar

But how do I use that since it's not react based? 但是由于它不是基于反应的,我该如何使用它?

First install it using npm, import it into your component, then you have to initialize it in your component using 首先使用npm安装它,将其导入到您的组件中,然后您必须使用来在组件中对其进行初始化

$('#mycalendar').calendar('behavior name', argumentOne, argumentTwo);

then you can initialize it in comonentDidMount life cycle method. 那么您可以使用comonentDidMount生命周期方法对其进行初始化。 like so 像这样

componentDidMount(){
$('#mycalendar').calendar('behavior name', argumentOne, argumentTwo);
}

After that you can use the celender in your jsx. 之后,您可以在jsx中使用celender。 here is the link which you can follow for more information https://github.com/mdehoog/Semantic-UI-Calendar 这是您可以单击以获取更多信息的链接https://github.com/mdehoog/Semantic-UI-Calendar

this is the jsbin like for more example https://jsbin.com/hubanufuva/1/edit?html,css,js,output 这是jsbin,例如更多示例https://jsbin.com/hubanufuva/1/edit?html,css,js,output

this link will help you to know how to use jquery with react https://medium.com/@shuvohabib/using-jquery-in-react-component-the-refs-way-969de9aa651f 该链接将帮助您了解如何将jquery与react https://medium.com/@shuvohabib/using-jquery-in-react-component-the-refs-way-969de9aa651f

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

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