# 被 APP Webview 雷的那些事 ### 1. 突然無法上傳、上傳失效 如果是從 Line、Facebook 或其他 APP 的 Webview 裡面,上傳可能會失效的原因:有可能是 input 的屬性 accept 的關係,無法限制上傳檔案類型,只能利用 chage 事件後,再去限制檔案類型。 問題: ```html <input type="file" accept="image/*" /> ``` 解法(Vue示例): ```vue <template> <input type="file" @change="uploadHandler($event)" /> </template> <script> export default { methods: { uploadHandler(event) { const file = event.target.files.item(0); if (!file.name.match(/\.(jpg|jpeg|png|gif)$/i)) { console.log(檔案必須是圖片格式!) return false; } } } } </script> ``` ###### tags: `JavaScript` `Webview`