在Flask模板中使用Semantic UI时文本框渲染异常求助
问题解决:Flask模板中textarea显示异常的修复
你的代码里textarea标签的内容部分多写了一个多余的>符号——{{request.form['content']}}>这里的末尾>是错误的,它没有被模板解析,直接作为文本留在了文本框里,所以你看到只显示单个>。
修正后的代码如下:
<div class="ui container"> <div class="html ui top attached segment" style="margin: 5px auto 0;"> <div class="ui top attached green massive label">Please paste text in the box below</div> <div class="ui form" id="inputForm" method="post"> <div class="field"> <textarea placeholder="Feel free to use free-text to input the patient phenotype description" id="note" name="content">{{request.form['content']}}</textarea> </div> </div> </div> </div>
额外建议:为避免表单未提交时request.form['content']不存在引发报错,可以改成{{ request.form.get('content', '') }},这样无提交内容时会显示空字符串,不会抛出KeyError。
内容的提问来源于stack exchange,提问作者Luca
相关产品推荐
相关产品推荐

