小程序基础学习(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>

相关推荐

  1. uniapp程序接入trtc-wx

    2024-01-11 08:26:04       37 阅读
  2. wx程序-button的bindtap事件

    2024-01-11 08:26:04       43 阅读
  3. wx程序-input事件改变数据

    2024-01-11 08:26:04       38 阅读
  4. 程序API wx.startLocationUpdateBackground 的使用

    2024-01-11 08:26:04       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-11 08:26:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-11 08:26:04       101 阅读
  3. 在Django里面运行非项目文件

    2024-01-11 08:26:04       82 阅读
  4. Python语言-面向对象

    2024-01-11 08:26:04       91 阅读

热门阅读

  1. 初学者的嵌入式 Linux 计划!

    2024-01-11 08:26:04       58 阅读
  2. 第七讲_css浮动

    2024-01-11 08:26:04       59 阅读
  3. Windows Copilot 更新及使用教程

    2024-01-11 08:26:04       177 阅读
  4. onlyOffice实践-在线协同word、ppt、excel编辑

    2024-01-11 08:26:04       139 阅读
  5. Go 企业级gRPC原理

    2024-01-11 08:26:04       50 阅读
  6. Vue3中的`ref`和`reactive使用中遇到的一些坑

    2024-01-11 08:26:04       56 阅读