强制使用 useSubmit 触发操作的方法,不进行任何检查的方式是什么?
P粉301523298
P粉301523298 2023-08-14 13:21:36
[React讨论组]
<p><strong>react-router-dom v6</strong></p><p>当我使用get方法提交操作时</p> <pre class="brush:php;toolbar:false;">useEffect(() =&gt; { if (!standardSelected) return; clearTimeout(sectionListTimeOutId); const clearTimeoutId = setTimeout(() =&gt; { console.log('&gt;&gt;&gt; use submit called'); submit({ standard_id: standardSelected }, { method: 'get' }); }, 1000); setSectionListTimeOutId(clearTimeoutId); }, [standardSelected]);</pre> <p>我的action函数没有被触发,因为action只会在除了"GET"方法之外的方法触发。</p><p><strong>我如何强制使用useSubmit来触发action而不检查任何内容。</strong></p>
P粉301523298
P粉301523298

全部回复(1)
P粉852114752

如果你想强制触发一个动作,你可以使用"post"方法,而不是"get"

useEffect(() => {
    if (!standardSelected) return;
    clearTimeout(sectionListTimeOutId);
    const clearTimeoutId = setTimeout(() => {
      console.log('>>> use submit called');
      submit({ standard_id: standardSelected }, { method: 'post' });
    }, 1000);
    setSectionListTimeOutId(clearTimeoutId);
  }, [standardSelected]);
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号