小程序的WXS模塊
5.演示模塊之間的引用
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ā)中也是很常見的。 |
|