微信小程序是之 wxs 方法

2021-12-07  本文已影响0人  缓慢的蜗牛

1.在根目录 创建wxs 文件夹


image.png

2.创建wxs/public.wxs 文件


内容.png
3.挂在公共方法public
var public = {
  // 折叠方法
  collapseState:function (collapseActive, collapseActiveItem) {
    if (collapseActive.indexOf(collapseActiveItem) >= 0) {
      return true;
    } else {
      return false;
    }
  }
};
module.exports.public = public;

4.页面内引入wxs

<wxs src="./../../wxs/public.wxs" module="public"></wxs>
说明:module="public" 为方法名
image.png

5.使用


image.png
动态添加class active.png
上一篇 下一篇

猜你喜欢

热点阅读