Blogger Information
Blog 39
fans 0
comment 0
visits 34670
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
微信小程序中的商品列表渲染
美丽城堡
Original
4562 people have browsed it

goods.wxml

实例

moduls="模型名字,对应本文件中要引用的地方"   

src="模型所在的文件地址"

<wxs module="filters" src="./goods.wxs" />

<!-- 商品列表渲染 -->
<view class="goods-show">
    <block wx:for="{{goods}}" wx:key="id">
        <view class="goods-box">
            <image src='/image/home.png'></image>
            <view class="goods-name">{{item.goodsName}}</view>
            <view class="goods-price">¥ {{filters.toFix(item.goodsPrice,1)}}</view>
        </view>
    </block>
</view>

运行实例 »

点击 "运行实例" 按钮查看在线实例

goods.wxs

实例

var filters = {
	toFix: function(val,count){
		return parseFloat(val).toFixed(count);
	}
}

module.exports = {
	toFix: filters.toFix
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

goods.wxss

实例

.goods-show{display: flex; flex-wrap: wrap;   }
.goods-box{width: 246rpx;  padding: 0 28prx; margin: 28rpx 0;  text-align: center; }

.goods-box image{width: 200rpx; height:200rpx; }
.goods-price{color: orange; font-size: 32rpx; }

运行实例 »

点击 "运行实例" 按钮查看在线实例

goods.js

实例

Page({
    data: {
        goods: [{
                goodsName: "商品1",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品2",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品3",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品4",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品5",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品6",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品7",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品8",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品9",
                goodsPrice: "66.6"
            },
            {
                goodsName: "商品9",
                goodsPrice: "66.6"
            },

        ]
    }

})

运行实例 »

点击 "运行实例" 按钮查看在线实例

app.wxss

实例

page{
	font-size: 28rpx; 
	color: #1a1a1a;
	font-family: microsoft yahei;
}

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post