Clojure China

请问一下一个组件的属性是另一个组件怎么用clojure编写

#1

如下面MobileStepper的nextButton属性Button

<MobileStepper
        steps={maxSteps}
        position="static"
        variant="text"
        activeStep={activeStep}
        nextButton={
          <Button size="small" onClick={handleNext} disabled={activeStep === maxSteps - 1}>
            Next
            {theme.direction === 'rtl' ? <KeyboardArrowLeft /> : <KeyboardArrowRight />}
          </Button>
        }
        backButton={
          <Button size="small" onClick={handleBack} disabled={activeStep === 0}>
            {theme.direction === 'rtl' ? <KeyboardArrowRight /> : <KeyboardArrowLeft />}
            Back
          </Button>
        }
      />
#2

其实就是正常的传进去就行了。

#3

你好,我的项目是reagent关联的项目,下面的的写法都是不行的,你能出以下具体代码吗?

[:> MobileStepper {:steps 5 :position "static" :variant "text"  :activeStep @activeStep
                        :nextButton  [:> Button {:size "small" :disabled (== @activeStep (- maxSteps 1)) :on-click #(swap! activeStep inc)}"Next"]
                        :backButton @(rf/subscribe [:> Button {:size "small" :disabled (== @activeStep 0) :on-click #(swap! activeStep dec) :value "Back"}])
                        }]
#4

:backButton #{ 这个是一个返回你需要的匿名函数 } :slight_smile:

(defn timer-component []
  (let [seconds-elapsed (r/atom 0)]
    (fn []
      (js/setTimeout #(swap! seconds-elapsed inc) 1000)
      [:div
       "Seconds Elapsed: " @seconds-elapsed])))

其实你也可以这样,把生成你需要组件的函数传进去就好了。道理和 on-click 一样的。

#5

谢谢,我试一下