企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ### 1. 在utils下新建wxs文件 ~~~ //将数组的长度变成指定长度 实现多余部分自动影藏 function filter(arr,index){ return arr.slice(0,index); } //不能使用es6语法 module.exports={ filter:filter } ~~~ ### 2. 在使用页面的wxml中引入 ~~~ <wxs src="../../utils/filter.wxs" module="tools"></wxs> ~~~ ### 3. 使用 ~~~ <view class="like"> <block wx:for="{{tools.filter(comments,7)}}" wx:key="index"> <v-tag comment="{{item.comment}}"></v-tag> </block> </view> ~~~