关于uni-app:uniapp在编译多端时vfor在H5和小程序端编译结果不一致

在应用 v-for=”number in productImage.cutCount”遍历一个数值时,

    <view v-for="number in productImage.cutCount">  
        <view>{{ number }}</view>  
    </view>

在微信小程序中,遍历进去的后果是

    <view>0</view>  
    <view>1</view>  
    <view>2</view>  
    <view>3</view>  
    <view>4</view>  

在H5中,遍历进去的后果是

    <view>1</view>  
    <view>2</view>  
    <view>3</view>  
    <view>4</view>  
    <view>5</view>

注意事项
在H5平台 应用 v-for 循环整数时和其余平台存在差别,如 v-for=”(item, index) in 10″ 中,在H5平台 item 从 1 开始,其余平台 item 从 0 开始,可应用第二个参数 index 来保持一致。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理