尝试使用
DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
Calcite Design Component上传文件时,我收到控制台错误
<calcite-input>
。但是,使用具有相同属性的普通 <input>
HTML 元素时没有问题。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Calcite Design System -->
<script type="module" src="https://js.arcgis.com/calcite-components/2.8.0/calcite.esm.js" integrity="sha384-YlUxwaQ8HMbpzggbtila0Yu/pQOahe1f79e6x6eN+H+Om1KPWOc7L0EQeYauqXrk" crossorigin="anonymous"></script>
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/2.8.0/calcite.css" />
<title>Test</title>
</head>
<body>
<form id="test-form" action="/" method="POST" enctype="multipart/form-data">
<calcite-input type="file" name="calcite_input_file" accept=".xlsx"></calcite-input> <!-- throws error in console, file not sent in request -->
<input type="file" name="input_file" accept=".xlsx" /> <!-- no errors, file sent in request -->
<button form="test-form" type="submit">Submit</button>
</form>
</body>
</html>
尝试从 Calcite Design Components v
2.7.0
切换到 2.8.0
,但问题仍然存在。可以只使用普通的 <input>
HTML 元素并添加我自己的样式以匹配方解石设计组件的外观,但希望避免额外的工作:D 希望我只是缺少 <calcite-input>
文件上传或设置所需的属性出问题了。
联系了 Esri 支持,他们将此报告为错误。一旦他们处理了错误,应该能够在here跟踪该错误。