分类 uniapp 下的文章

0.png
1.png

解决方法有两种:

  1. 修改一下 @babel/runtime/helpers/typeof.js 文件,内容修改为代码片段的。目的是添加"@babel/helpers - typeof";这一句在代码中,让babel识别出这是一个特殊的helper文件,不对它进行处理。
  2. 参考配置说明 https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html 修改一下 babelSetting 的 outputPath 成其他路径。

- 阅读剩余部分 -

问题

每当使用微信开发者工具预览小程序时,均会在控制台(Console)看到警告(Warn)信息:Now you can provide attr wx:key for a wx:for to improve performance

原因

uniapp的v-for写法导致。

修改前的写法如下:

<view class="comment-content" v-for="(item,index) in commentList">
    <!-- 评论用户头像 -->
    <view class="comment-content-left">
        <image class="comment-content-headImage" :src="item.formHead" mode="center"></image>
    </view>
    <view class="comment-content-right">
        <!-- 评论用户名 -->
        <view class="comment-content-name">{{item.formNick}}</view>
        <!-- 评论内容 -->
        <view class="comment-content-text">{{item.content}}</view>
        <!-- 评论日期 -->
        <view class="comment-content-time">{{item.commentTime}}</view>
    </view>
</view>

解决方法

v-for 搭配 key 使用。

- 阅读剩余部分 -