转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-18/

上一节,讲了模板的概念,其实小程序还提供了模块的概念。源码:https://github.com/limingios/wxProgram.git 中的No.8

小程序的WXS模块

  1. js代码块可以在页面中被引入使用
  2. 定义*.wxs,module.exports暴露接口和属性

    从私有到公用的概念,通过暴露就可以公有话。

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

  1. 演示模块的概念
    >每一个 .wxs 文件和 标签都是一个单独的模块。每个模块都有自己独立的作用域。即在一个模块里面定义的变量与函数,默认为私有的,对其他模块不可见。一个模块要想对外暴露其内部的私有变量与函数,只能通过 module.exports 实现。
<!wxs.wxml-->
<view class="container">
<wxs src="../wxs/module.wxs" module="item"></wxs>
<view>{{item.name}}</view>
<view>{{item.age}}</view>
<view>{{item.method("这是一个参数传递")}}</view> <view>{{item.name}}</view>
<view>{{item.age}}</view>
<view>{{item.method("这是一个参数传递")}}</view> <view>{{item.name}}</view>
<view>{{item.age}}</view>
<view>{{item.method("这是一个参数传递")}}</view>
</view>
// module.wxs
var name ="公众号:编程坑太多"
var age = 18; var method = function(obj){
return obj;
} module.exports ={
name :name,
age : age,
method :method
}

PS : 通过src进行导入,然后在引入module参数进行调用里面的属性和接口方法。

「小程序JAVA实战」小程序模块页面引用(18)的更多相关文章

  1. 「小程序JAVA实战」小程序的flex布局(22)

    转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-22/ 之前已经把小程序的框架说完了,接下来说说小程序的组件,在说组件之前,先说说布局吧.源码:ht ...

  2. 「小程序JAVA实战」小程序模块之间引用(19)

    转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-19/ 上一节,讲了页面引用模块的概念,如果是模块之前引用呢?源码:https://github.c ...

  3. 「小程序JAVA实战」小程序的留言和评价功能(70)

    转自:https://idig8.com/2018/10/28/xiaochengxujavashizhanxiaochengxudeliuyanhepingjiagongneng69/ 目前小程序这 ...

  4. 「小程序JAVA实战」小程序的举报功能开发(68)

    转自:https://idig8.com/2018/09/25/xiaochengxujavashizhanxiaochengxudeweixinapicaidancaozuo66-2/ 通过点击举报 ...

  5. 「小程序JAVA实战」小程序的个人信息作品,收藏,关注(66)

    转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudegerenxinxizuopinshoucangguanzhu65 ...

  6. 「小程序JAVA实战」小程序的关注功能(65)

    转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudeguanzhugongneng64/ 在个人页面,根据发布者个人和 ...

  7. 「小程序JAVA实战」小程序的视频点赞功能开发(62)

    转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudeshipindianzangongnengkaifa61/ 视频点 ...

  8. 「小程序JAVA实战」小程序的springboot后台拦截器(61)

    转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxudespringboothoutailanjieqi60/ 之前咱们把 ...

  9. 「小程序JAVA实战」小程序首页视频(49)

    转自:https://idig8.com/2018/09/21/xiaochengxujavashizhanxiaochengxushouyeshipin48/ 视频显示的内容是视频的截图,用户的头像 ...

随机推荐

  1. wamp配置局域网访问

    Apache的版本是2.4.9. <Directory "D:/wamp/www/">    #    # Possible values for the Option ...

  2. python当前路径

    os.getcwd()获取系统路径 sys.path [0]获取当前路径

  3. java的try-with-resource机制

    在java7之后可以使用try(resource1, resource2){...}这样声明之后,在try{}执行完成之后或者抛异常跳出,都会调用reouce1.close(),resource2.c ...

  4. ecmall 挂件开发实例一

     (参考网上相关文章,进行测试点评,下述方法测试成功) 1:在页面上添加要展示的页面模块 <div class="left" area="bottom_foot&q ...

  5. 洛谷 4525 && 洛谷 4526 【模板】自适应辛普森法

    题目:https://www.luogu.org/problemnew/show/P4525 https://www.luogu.org/problemnew/show/P4526 参考:https: ...

  6. Java API 操作Zookeeper

    一.依赖 <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookee ...

  7. Eclipse git插件使用

    1.Eclipse git插件使用 1)配置提交用户名和邮箱 2)在eclipse中选择Show View 搜索git 3)点击clone按钮 选择代码保存路径 4)导入项目 5)git插件功能介绍 ...

  8. jeecg选择按钮带入其他单据值

    前端的标签 <input class="inputxt" id="fshimian" name="fshimian" ignore=& ...

  9. MOSS 2013研究系列---Win2008R2 建立域控时候,报密码不符合要求解决办法

    今天远程给Win2008R2装AD域控的时候,突然报如下的错误页面: 修改了密码,将密码强度设置复杂了,但是,仍然会弹出这个错误页面,估计是因为远程账号的关系,于是再网上搜下了一下,找到了一个解决方案 ...

  10. redis底层数据结构--简单动态字符串 链表 字典 跳跃表 整数集合 压缩列表

    1.动态字符串 redis中使用c语言的字符床存储字面量,默认字符串存储采用自己构建的简单动态字符串SDS(symple dynamic string) redis包含字符串的键值对都是用SDS实现的 ...