GithubHelp home page GithubHelp logo

Comments (8)

hcanyz avatar hcanyz commented on July 18, 2024

能否提供一个最小复现的 demo , 和一些基础信息(webview版本、手机型号、系统版本)

初步怀疑是跨域了。
assets 跟 服务器部署,走的 uri scheme 不一样。 android 默认是不允许 http|https 访问 file 域文件的。需要通过 setAllowUniversalAccessFromFileURLs 开启访问权限。开启这个需要注意安全问题,防止被三方页面盗用。

from zjsbridge.

phoenixsky avatar phoenixsky commented on July 18, 2024

我这边直接用你的vue代码,部署起来和通过assets加载。返回图片地址 在前端展示 服务器部署的是不好用的。

from zjsbridge.

phoenixsky avatar phoenixsky commented on July 18, 2024

你那边部署的方式,图片可以正常展示么。如果只有我这不行的话,我晚些整个demo再试试。

from zjsbridge.

hcanyz avatar hcanyz commented on July 18, 2024

我试了下是有这个问题
看下面日志,是被 android 拦截了。

"choosePhotos success, ret:[{"nativeResourceUrl":"content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20210331_220934.jpg"}]", source: http://192.168.43.27:8080/js/chunk-vendors.44073e36.js (17)

"Not allowed to load local resource: content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2FIMG_20210331_220934.jpg", source: http://192.168.43.27:8080/ (0)

from zjsbridge.

phoenixsky avatar phoenixsky commented on July 18, 2024

嗯,图片可能是要单独处理下了,不知道作者是否有此计划?

from zjsbridge.

hcanyz avatar hcanyz commented on July 18, 2024

这个问题有时间我会研究下。

目前有俩种方式可以解决

  • (推荐)使用 <input type="file" />,android 端实现 onShowFileChooser
  • 参考 d39e964 ,使用虚拟资源的方式把文件传递给 javascript

from zjsbridge.

hcanyz avatar hcanyz commented on July 18, 2024

https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader

可以试下这个,google 提供的本地资源共享方案。类似于项目中的 ”虚拟资源“

from zjsbridge.

phoenixsky avatar phoenixsky commented on July 18, 2024

感谢大佬,我研究下

from zjsbridge.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.