乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      「小程序JAVA實(shí)戰(zhàn)」小程序模塊之間引用(19)

       印度阿三17 2019-07-31

      上一節(jié),講了頁面引用模塊的概念,如果是模塊之前引用呢?源碼:https://github.com/limingios/wxProgram.git 中的No.8

      小程序的WXS模塊

      1. js代碼塊可以在頁面中被引入使用


      2. 定義*.wxs,module.exports暴露接口和屬性

        從私有到公用的概念,通過暴露就可以公有話。

      3. require函數(shù)

      4. 官方的闡述
        >https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/01wxs-module.html

      5.演示模塊之間的引用

      在.wxs模塊中引用其他 wxs 文件模塊,可以使用 require 函數(shù)。
      引用的時(shí)候,要注意如下幾點(diǎn):
      * 只能引用 .wxs 文件模塊,且必須使用相對(duì)路徑。
      * wxs 模塊均為單例,wxs 模塊在第一次被引用時(shí),會(huì)自動(dòng)初始化為單例對(duì)象。多個(gè)頁面,多個(gè)地方,多次引用,使用的都是同一個(gè) wxs 模塊對(duì)象。
      * 如果一個(gè) wxs 模塊在定義之后,一直沒有被引用,則該模塊不會(huì)被解析與運(yùn)行。

      wxs.wxml

      <!wxs.wxml-->
      <view?class="container">
      ??<wxs?src="../wxs/module.wxs"?module="item"></wxs>
      ??<view>{{item.name}}</view>
      ??<view>{{item.age}}</view>
      ??<view>{{item.method("這是一個(gè)參數(shù)傳遞")}}</view>
      
      ??<view>{{item.name}}</view>
      ??<view>{{item.age}}</view>
      ??<view>{{item.method("這是一個(gè)參數(shù)傳遞")}}</view>
      
      ??<view>{{item.name}}</view>
      ??<view>{{item.age}}</view>
      ??<view>{{item.method("這是一個(gè)參數(shù)傳遞")}}</view>
      </view>

      module.wxs

      //?module.wxs
      var?module2?=?require("../wxs/module2.wxs")
      var?name?="個(gè)人網(wǎng)站:idig8.com"
      var?age?=?18;
      
      var?method?=?function(obj){
      ??console.log(module2.name);
      ??console.log(module2.age);
      ??return?obj;
      }
      
      module.exports?={
      ??name?:name,
      ??age?:?age,
      ??method?:method
      }

      module2.wxs

      //?module.wxs
      var?name?="公眾號(hào):編程坑太多"
      var?age?=?28;
      
      var?method?=?function(obj){
      ??return?obj;
      }
      
      module.exports?={
      ??name?:name,
      ??age?:?age,
      ??method?:method
      }

      PS:這次就是針對(duì)模塊引入模塊的方式,這種在實(shí)際開發(fā)中也是很常見的。


      來源:https://www./content-1-372001.html

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多