You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ha...@apache.org on 2018/12/21 02:15:47 UTC

[incubator-weex-site] branch draft updated: update doc for assetpath (#255)

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

hanks 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 0a22316  update doc for assetpath (#255)
0a22316 is described below

commit 0a22316299c522468977c588646faaaf508e2e6f
Author: chen <lu...@users.noreply.github.com>
AuthorDate: Fri Dec 21 10:15:43 2018 +0800

    update doc for assetpath (#255)
---
 docs/guide/advanced/asset-path.md    | 18 ++++++++--------
 docs/zh/guide/advanced/asset-path.md | 40 ++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/docs/guide/advanced/asset-path.md b/docs/guide/advanced/asset-path.md
index b1f5ca1..329ba38 100644
--- a/docs/guide/advanced/asset-path.md
+++ b/docs/guide/advanced/asset-path.md
@@ -9,24 +9,26 @@ 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
+### 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.
+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.
+
+### remote
 
-* HTTP/HTTPS
-It's working in the same way as in web, Weex support these at very beginning.
+* `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.
+* `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
 
diff --git a/docs/zh/guide/advanced/asset-path.md b/docs/zh/guide/advanced/asset-path.md
index e69de29..b94e2ca 100644
--- a/docs/zh/guide/advanced/asset-path.md
+++ b/docs/zh/guide/advanced/asset-path.md
@@ -0,0 +1,40 @@
+---
+title: 资源路径
+type: guide
+group: 高阶特性
+order: 8.1
+version: 2.1
+has_chapter_content: true
+---
+
+<!-- toc -->
+
+本文将介绍 Weex 中 uri(url) 的用法。包括使用图像、字体等资源,处理相对路径以及如何访问本地及打包的资源文件。
+
+## Schemes
+
+### 本地资源
+
+Weex SDK 提供 `local`  scheme 来访问打包在应用程序中的资源,此 scheme 无法在 H5 环境下使用。目前,开发者可以在 `image` 组件和字体文件中使用本地资源。
+
+  * 在 iOS 中,Weex 会在 `bundle resources` 中查找。例如,`image` 组件的 `src` 属性为 `local:///app_icon'`, Weex 会加载 `bundle resouce` 中名为 `app_icon` 的图像资源,而字体文件也以相同的方式工作。
+
+  * 在 Android 中,`image` 组件将从 `drawable` 资源文件夹加载,如  `res/drawable-xxx`。但加载字体文件是不同的,Android 框架无法从 `res` 加载字体文件,因此 SDK 将从 `asserts` 文件夹加载它。
+
+### 远程资源 
+
+* HTTP/HTTPS,它的工作方式与 web 相同,Weex 一直支持这种方式。
+
+* File ,使用 `file`  scheme 访问本地磁盘文件。这个方案有其局限性:
+	* 你不应该在源页面中硬编码文件 url。因为不管它是否运行在不同的平台(iOS,Android)上,同一平台不同机型的结果也可能不同,这取决于具体的设备。
+	* 所以一种可行的方案是在运行时动态获取文件 url,你可以使用它来显示本地磁盘的图像,或者稍后上传它。
+
+## 相对路径
+
+[与我们在 HTML 中的用法类似](https://www.w3.org/TR/html4/types.html#type-uri),Weex 以相同的方式处理相对路径。以`/`、`.`、`..`、`//` 开头的相对 URI 将相对于 bundle url 解析。
+
+这意味着, 一个以 `/` 开头的路径将是相对于 JS Bundle 文件的根文件夹。`.` 则是当前文件夹,`..` 是父文件夹。 `//` 则被解析为与 JS Bundle 相同的 scheme。
+
+## URI Adapter
+
+以上所有是默认实现,开发者可以通过提供一个 `URI Adapter` 来扩展或覆盖默认实现。与其他 Adapter 相同,应在 Weex SDK 初始化之前设置自定义 Adapter。