[英]How to set input value to current day in reflex?
I am using reflex-platform
with obelisk
.我正在使用带有
obelisk
reflex-platform
。 This is my frontend code to get the current date这是我获取当前日期的前端代码
pb <- getPostBuild
postBuildTime <- performEvent $ pb $> liftIO getCurrentTime
let today = Text.pack . formatTime defaultTimeLocale "%F" <$> postBuildTime
I can confirm that this works by putting我可以通过放置来确认这是否有效
dynText =<< holdDyn "loading" today
which does not even display "loading" for a split second but instead shows "2021-03-26" as expected in the browser (Google Chrome).它甚至不会在一瞬间显示“正在加载”,而是在浏览器(谷歌浏览器)中显示“2021-03-26”。
However, trying to put the today
event into an <input>
doesn't work.但是,尝试将
today
事件放入<input>
是行不通的。 This is the code:这是代码:
foo <- inputElement $ def & inputElementConfig_setValue .~ today
The <input>
stays blank. <input>
保持空白。
Even weirder: In my actual code the <input>
has an initial value via inputElementConfig_initialValue.~ "BAAAR"
, which doesn't show either.更奇怪的是:在我的实际代码中,
<input>
通过inputElementConfig_initialValue.~ "BAAAR"
有一个初始值,它也没有显示。 Yet a dynamic text created like然而,创建的动态文本就像
dynText =<< holdDyn "" foo
DOES show "BAAAR" for a split second.确实显示“BAAAR”一瞬间。
And to calm any paranoia, I tested the inputElementConfig_setValue
with a simple button, which worked fine.为了平息任何偏执,我用一个简单的按钮测试了
inputElementConfig_setValue
,效果很好。 Ie I can set the value of <input>
by clicking on a button.即我可以通过单击一个按钮来设置
<input>
的值。
So the postBuildTime
event works and the inputElementConfig_setValue
works, but the combination of the two leaves the <input>
blank.所以
postBuildTime
事件有效并且inputElementConfig_setValue
有效,但是两者的组合使<input>
为空。
EDIT编辑
Minimal example including instructions on how to run and screenshot of the result:最小示例,包括有关如何运行的说明和结果的屏幕截图:
https://github.com/rubenmoor/reflex-bug-pbtime https://github.com/rubenmoor/reflex-bug-pbtime
https://github.com/reflex-frp/reflex-dom/commit/93f0f4bd00e1dc871d193d7d53d5d7f2dbb518af https://github.com/reflex-frp/reflex-dom/commit/93f0f4bd00e1dc871d193d7d53d5d7f2dbb518af
Looks like this was a bug, that has been fixed in reflex-dom
.看起来这是一个错误,已在
reflex-dom
中修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.