我正在实现一个 .NET MAUI 桌面应用程序,该应用程序从 Windows 中的本地文件夹读取文件,我不想让用户再次直接从应用程序保存文件。
有没有办法禁用使用 webview 标签附带的保存按钮?
您可以尝试调用一些 JavaScript 来删除按钮或设置它们的“display:hidden;”。 我们有一种方法来评估 JS 与 WebView.EvaluateJavaScriptAsync。 所以你可以写这样的东西:
await WebView.EvaluateJavaScriptAsync(
"""
// or any other JS function to get the elements, not sure what classes or IDs they have
let saveButton = document.getElementById('#save');
saveButton.style.display = 'none';
"""
)
我没有尝试过也没有运行过这个,但我认为它可以完成这项工作。