小程序基础学习(wxs)

复制代码
<!--pages/three/three.wxml-->
<navigation-bar title="牧原" back="{{false}}" color="black" background="#FFF"></navigation-bar>
<wxs module="format">
function formatPrice(price){
  return "$" + price
}
module.exports={
  formatPrice:formatPrice
}
</wxs>
<view>
  <block wx:for="{{book}}" wx:key="id" >
  <view>
    name:{{item.name}}  ----price{{format.formatPrice(item.price)}}
  </view>
    
  </block>
</view>

data: {
    book:[
      {
        "id":123,
        "name":"牛马程序员",
        "price":100
      },
      {
        "id":1234,
        "name":"牛马程序员4",
        "price":1004
      },
      {
        "id":1235,
        "name":"牛马程序员5",
        "price":1005
      },
      {
        "id":1236,
        "name":"牛马程序员6",
        "price":1006
      },
  ]

  },

第二张方案吧wxs导出到外部文件

复制代码
function formatPrice(price){
  return "$" + price
}
module.exports={
  formatPrice:formatPrice
}

再导入外部文件路径即可

复制代码
<wxs module="format" src="/utils/format.wxs">

</wxs>
相关推荐
aiguangyuan14 分钟前
基于BERT的中文命名实体识别实战解析
人工智能·python·nlp
量子-Alex16 分钟前
【大模型RLHF】Training language models to follow instructions with human feedback
人工智能·语言模型·自然语言处理
晚霞的不甘21 分钟前
Flutter for OpenHarmony 实现计算几何:Graham Scan 凸包算法的可视化演示
人工智能·算法·flutter·架构·开源·音视频
陈天伟教授31 分钟前
人工智能应用- 语言处理:04.统计机器翻译
人工智能·自然语言处理·机器翻译
Dfreedom.38 分钟前
图像处理中的对比度增强与锐化
图像处理·人工智能·opencv·锐化·对比度增强
wenzhangli742 分钟前
OoderAgent 企业版 2.0 发布的意义:一次生态战略的全面升级
人工智能·开源
AI_56781 小时前
SQL性能优化全景指南:从量子执行计划到自适应索引的终极实践
数据库·人工智能·学习·adb
cyyt1 小时前
深度学习周报(2.2~2.8)
人工智能·深度学习
阿杰学AI1 小时前
AI核心知识92——大语言模型之 Self-Attention Mechanism(简洁且通俗易懂版)
人工智能·ai·语言模型·自然语言处理·aigc·transformer·自注意力机制
陈天伟教授1 小时前
人工智能应用- 语言处理:03.机器翻译:规则方法
人工智能·自然语言处理·机器翻译