You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by zs...@apache.org on 2018/12/14 04:00:41 UTC

[incubator-weex-site] branch draft updated: Update asset-path.md

This is an automated email from the ASF dual-hosted git repository.

zshshr pushed a commit to branch draft
in repository https://gitbox.apache.org/repos/asf/incubator-weex-site.git


The following commit(s) were added to refs/heads/draft by this push:
     new aea1e95  Update asset-path.md
aea1e95 is described below

commit aea1e95aa77c2dd0000a9dab81af7d68093cc18c
Author: zshshr <zh...@gmail.com>
AuthorDate: Fri Dec 14 12:00:37 2018 +0800

    Update asset-path.md
---
 docs/guide/advanced/asset-path.md | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/docs/guide/advanced/asset-path.md b/docs/guide/advanced/asset-path.md
index e69de29..b1f5ca1 100644
--- a/docs/guide/advanced/asset-path.md
+++ b/docs/guide/advanced/asset-path.md
@@ -0,0 +1,38 @@
+---
+title: Asset Path
+type: guide
+group: Advanced Guide
+order: 8.1
+version: 2.1
+has_chapter_content: true
+---
+
+<!-- toc -->
+
+<span class="weex-version">0.9</span>
+
+This article will cover uri (url) usage in Weex. Including using image/typeface resources, deal with relative uri and how to access local and packaged asset files.
+
+## Schemes
+
+* Local
+Weex SDK provide `local` scheme to access resources packaged with application, and of cource, it's not working in the HTML5 runtime.
+Currently, developers can use this scheme with `image` and text's font file location.
+  * In iOS, it's always locate file in 'bundle resources'. For example, a `image` component with `local:///app_icon` will load image file named 'app_icon' in bundle resouce, and font file work in the same way.
+  * In Android, image component will load from 'drawable' resource folder like 'res/drawable-xxx'. But load font file is different, android framework can not load font file from 'res', so SDK will load it from `assets` folder.
+
+* HTTP/HTTPS
+It's working in the same way as in web, Weex support these at very beginning.
+
+* File
+Use `file` scheme to access local disk file. This scheme has its limitations: You would not hard coded a file url in source page. Because not matter it's running in different platform(iOS, Android) or not, the content will be totally different in another device, which is depend to the specific device.
+So one possible case is getting the file url in runtime dynamically, which you can use it to display a local disk image, or maybe upload it later.
+
+## Relative URI
+
+[Like we do in HTML](https://www.w3.org/TR/html4/types.html#type-uri), weex process 'relative URI' in the same way. The relative URI, which start with `/`,`.`,`..`,`//`, will resolve by the bundle url.
+Means URL start with `/` will resolve to the root folder as bundle js file, `.` and `..` will resolve to current and parent folder, and `//` will resolve to same scheme bundle js have.
+
+## URI Adapter
+
+All the above is the default implementation, developers can extend or override these their own by providing a 'URI Adapter'. Same as the other adapters, Custom adapter should be set before Weex SDK is initializing.