MorJS 文件維度 實(shí)現(xiàn)效果

2024-01-17 15:09 更新

文件默認(rèn)輸出就是(支付寶)小程序的版本,因此條件編譯主要是針對(duì)域外的小程序(如:微信小程序)

如:自定義組件(頁(yè)面也是如此)需要做兩端的區(qū)分 頁(yè)面引用該組件的代碼:

{
  "usingComponents": {
    "demo": "../../components/demo/index"
  }
}

默認(rèn)情況下,組件都包含了axml/acss/js/json四個(gè)文件

- components
  - demo
    - index.axml
    - index.acss
    - index.js
    - index.json

由于在微信小程序下。邏輯差異較大??梢灾苯佑?code>.wx來(lái)做區(qū)分

- components
  - demo
    - index.axml(支付寶版本)
    - index.acss(支付寶版本)
    - index.js(支付寶版本)
    - index.json
    - index.wx.axml(微信版本)
    - index.wx.acss(微信版本)
    - index.wx.js(微信版本)

在 MorJS 編譯輸出的時(shí)候,在輸出目錄下_wechat,會(huì)優(yōu)先用.wx的版本來(lái)生成對(duì)應(yīng)的微信版本源文件

- _wechat
  - components
    - demo
      - index.wxml
      - index.wxss
      - index.js
      - index.json

而在Pagejson中的usingComponents是不需要做任何修改的,依然保留原本的引用路徑即可。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)