# wxml/wx-key

# Backgroud

wx:key

If wx:key, is not provided, a warning is reported. If you know that this list is static or the order is not important, you can ignore the warning.

Wechat Document Reference (opens new window)

# Motivation

hint developer don't forget add wx:key when loop data in wxml.

<!-- ✓ GOOD --> <view wx:for="{{list}}" wx:key="goodsId"> <view>item.title</view> </view> <!-- ✗ BAD --> <view wx:for="{{list}}"> <view>item.title</view> </view>
Now loading...

💡 tips

You can edit code via online editor, it's online REPL, try to fix eslint problem !

# Config

No special options, normal config is ok

{ "wxml/wx-key": "error" }

# Version

This rule was introduced in eslint-plugin-wxml v0.3.0

# Implementation