【发布时间】:2021-02-13 00:09:30
【问题描述】:
我正在尝试让 HTML 文件上传控制在 WASM 上运行。到目前为止,我已尝试执行以下操作:
[HtmlElement("input")]
public class FilePickerView : FrameworkElement
{
public FilePickerView()
{
// XAML behavior: a non-null background is required on an element to be "visible to pointers".
// Uno reproduces this behavior, so we must set it here even if we're not using the background.
// Not doing this will lead to a `pointer-events: none` CSS style on the control.
Background = new SolidColorBrush(Colors.Transparent);
this.SetHtmlAttribute("type", "file");
}
}
然后在视图中:
<wasm:FilePickerView Height="35" Width="300" x:Name="filePicker" HorizontalAlignment="Left" />
我得到了显示的控件,我可以点击它,它会显示我选择的文件的名称。
在这之后我很迷茫。
我想做两件事:
- 在后面的代码中访问文件路径。
- 将文件内容发送到后台代码进行处理。
不胜感激。
我浏览了文档中的以下页面:
- (Wasm) 处理自定义 HTML 事件 - https://qa.website.platform.uno/docs/articles/wasm-custom-events.html
- 将现有 JavaScript 组件嵌入到 Uno-WASM - 第 1 部分 - https://qa.website.platform.uno/docs/articles/interop/wasm-javascript-1.html
- 将现有 JavaScript 组件嵌入到 Uno-WASM - 第 2 部分 - https://qa.website.platform.uno/docs/articles/interop/wasm-javascript-2.html
- 将现有 JavaScript 组件嵌入到 Uno-WASM - 第 3 部分 - https://qa.website.platform.uno/docs/articles/interop/wasm-javascript-3.html
【问题讨论】:
标签: uno-platform