Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何准备React.js组件作为外部试剂组件在ClojureScript中使用?_Reactjs_Clojurescript_Reagent - Fatal编程技术网

Reactjs 如何准备React.js组件作为外部试剂组件在ClojureScript中使用?

Reactjs 如何准备React.js组件作为外部试剂组件在ClojureScript中使用?,reactjs,clojurescript,reagent,Reactjs,Clojurescript,Reagent,我想将此React.js组件用作ClojureScript应用程序中的外来试剂组件: 但是,此组件在存储库中不可用: 如果目录中有React.js组件,那么将其与试剂一起使用将与下面的示例一样简单 (ns demo.views (:require [reagent.core :as reagent] [cljsjs.reactable]]) (defn example [] [:div [:> Reactable.Table {:data

我想将此React.js组件用作ClojureScript应用程序中的外来试剂组件:

但是,此组件在存储库中不可用:

如果目录中有React.js组件,那么将其与试剂一起使用将与下面的示例一样简单

(ns demo.views
  (:require [reagent.core :as reagent]
            [cljsjs.reactable]])

(defn example []
  [:div
  [:> Reactable.Table
    {:data (clj->js [
                 {:name "Foo" :section 51}
                 {:name "Bar" :section 51}
                 ])}
    ]
   ]
  )
我想知道如何处理React电子表格组件,以便以类似的简单方式使用它。如何准备React.js组件作为外部试剂组件在ClojureScript中使用?请提供明确的配方类型说明


注意:这个问题看起来很相似,但没有回答我的问题。

它归结为您希望如何进行JavaScript互操作。。。您有3种选择:

  • 包含HTML文件中的js
  • 作为编译的一部分构建它
  • 将其作为库包含
  • 我鼓励你尝试(3);这并不困难,只需按照CLJSJS上的步骤将外部JS包括在构建中,然后使用试剂在试剂视图中使用组件。尽量不要依赖像CLJSJS这样的项目

    自己做这件事会让你控制你的项目

    project.clj

    :foreign-libs [{:file "https://rawgit.com/felixrieseberg/React-Spreadsheet-Component/master/dist/spreadsheet.js"
                    :provides  ["no-idea"]}]
    
    在视图中

    (def reactable-table (r/adapt-react-class js/Reactable.Table))
    
    (defn example []
      [:div
      [reactable-table
        {:data (clj->js [
                     {:name "Foo" :section 51}
                     {:name "Bar" :section 51}])}]])
    

    但是请注意,这个组件捆绑了很多依赖项(jQuery)。在clojurescript/试剂中,您自己制作这样的组件可能会更好。

    您是说有了这三个选项,我可以将其用作外部试剂组件吗?我认为只有选择3才有可能。至于选项3,我看了那个描述,当然,我发现步骤4是一个非常困难的步骤。对于步骤4,你可以使用一个生成器,这样你就不需要手动执行外部操作。现在这真的很有帮助!归根结底就是制作一个:外部文件,对吗?关键是我不知道如何创建这样一个文件。