收藏
回答

利用模板来做小程序,我是小白,求大哥来解救下面出了什么问题?

VM189:22 WXMLRT_$gwx:./common/template/list.wxml:view:2:4: wx:key="{{index}}" does not look like a valid key name (did you mean wx:key="index" ?)

_wp @ VM189:22

d_.<computed>.list @ VM189:1280

m8 @ VM189:1396

(anonymous) @ VM189:1613

y @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

u.create @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

O.prepare @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

xt @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

It @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Nt.emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

c @ asdebug.js:10

u @ asdebug.js:10

(anonymous) @ asdebug.js:1

f @ asdebug.js:1

g @ asdebug.js:1

(anonymous) @ asdebug.js:1

_ws.onmessage @ asdebug.js:1

[WXML Runtime warning] ./pages/register/register.wxml

 wx:key="{{item.id}}" does not look like a valid key name (did you mean wx:key="id" ?)

  42 |       <view class="text">

  43 |         <radio-group class="radio-group">

> 44 |           <label wx:for="{{sex}}" wx:for-item="item" wx:key="{{item.id}}">

     |            ^

  45 |             <radio value="{{item.value}}" checked="{{item.checked}}" /> {{item.name}}

  46 |           </label>

  47 |         </radio-group>

[WXML Runtime warning] ./pages/register/register.wxml

 wx:key="{{index}}" does not look like a valid key name (did you mean wx:key="index" ?)

  148 |       </view>

  149 |       <view class="study-wrap">

> 150 |         <view class="addstudy delestudy" bind:tap="goAdd" wx:for="{{studyInfo}}" wx:key="{{index}}">

      |          ^

  151 |           <text class="add delete" catch:tap="deleAdd" data-index="{{index}}">x</text>

  152 |           <text class="school">{{item.school}}</text>

  153 |           <text class="zye">{{item.zye}}</text>

[WXML Runtime warning] ./pages/register/register.wxml

 wx:key="{{index}}" does not look like a valid key name (did you mean wx:key="index" ?)

  165 |       </view>

  166 |       <view class="study-wrap">

> 167 |         <view class="addstudy delestudy" bind:tap="goAddwork" wx:for="{{workInfo}}" wx:key="{{index}}">

      |          ^

  168 |           <text class="add delete" catch:tap="deleAddwork" data-index="{{index}}">x</text>

  169 |           <text class="school">{{item.name}}</text>

  170 |           <text class="zye">{{item.zwei}}</text>

register.js? [sm]:101 {type: "tap", timeStamp: 107257, target: {…}, currentTarget: {…}, detail: {…}, …}

register.js? [sm]:101 {type: "tap", timeStamp: 108054, target: {…}, currentTarget: {…}, detail: {…}, …}

register.js? [sm]:116 {type: "tap", timeStamp: 109601, target: {…}, currentTarget: {…}, detail: {…}, …}

register.js? [sm]:116 {type: "tap", timeStamp: 110188, target: {…}, currentTarget: {…}, detail: {…}, …}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

DevTools: CPU profile parser is fixing 4 missing samples.

register.js? [sm]:95 {type: "tap", timeStamp: 218265, target: {…}, currentTarget: {…}, detail: {…}, …}

register.js? [sm]:88 picker发送选择改变,携带值为 1980-07-05

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

register.js? [sm]:131 form发生了submit事件,携带数据为: {}

[WXML Runtime warning] ./common/template/list.wxml

 wx:key="{{index}}" does not look like a valid key name (did you mean wx:key="index" ?)

  1 | <template name="list">

> 2 |   <view class="list" wx:for="{{list}}" wx:key="{{index}}"  >

    |    ^

  3 |     <view class="check-box" wx:if="{{isDelete}}">

  4 |       <checkbox-group  bind:change="checkboxChange" data-id="{{item.ID}}">

  5 |         <label class="checkbox">

asdebug.js:10 POST http://127.0.0.1wx/index/init net::ERR_NAME_NOT_RESOLVED(env: Windows,mp,1.06.2301040; lib: 2.6.0)

v @ asdebug.js:10

createRequestTask @ asdebug.js:10

invoke @ asdebug.js:10

r @ asdebug.js:10

invoke @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

X @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

ji @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

i @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

t @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

value @ apihook.js?t=wechat&s=1675004718479&v=0cffbba9918afb1342c18e2fdfb25ef5:1

getAtrList @ index.js? [sm]:235

onLoad @ index.js? [sm]:65

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

p.__callPageLifeTime__ @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Ct @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

It @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Nt.emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

c @ asdebug.js:10

u @ asdebug.js:10

(anonymous) @ asdebug.js:1

f @ asdebug.js:1

g @ asdebug.js:1

(anonymous) @ asdebug.js:1

_ws.onmessage @ asdebug.js:1

Show 7 more frames

asdebug.js:10 POST http://127.0.0.1wx/hits/add net::ERR_NAME_NOT_RESOLVED(env: Windows,mp,1.06.2301040; lib: 2.6.0)

v @ asdebug.js:10

createRequestTask @ asdebug.js:10

invoke @ asdebug.js:10

r @ asdebug.js:10

invoke @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

X @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

ji @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

i @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

t @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

value @ apihook.js?t=wechat&s=1675004718479&v=0cffbba9918afb1342c18e2fdfb25ef5:1

addhits @ util.js? [sm]:101

onLoad @ index.js? [sm]:66

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

p.__callPageLifeTime__ @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Ct @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

It @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Nt.emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

c @ asdebug.js:10

u @ asdebug.js:10

(anonymous) @ asdebug.js:1

f @ asdebug.js:1

g @ asdebug.js:1

(anonymous) @ asdebug.js:1

_ws.onmessage @ asdebug.js:1

Show 7 more frames

WAService.js?t=wechat&s=1675004718479&v=2.6.0:1 request:fail (env: Windows,mp,1.06.2301040; lib: 2.6.0)

Xe @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Nt.emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Wi @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

c @ asdebug.js:10

(anonymous) @ asdebug.js:10

a.emit @ asdebug.js:1

callback @ asdebug.js:10

(anonymous) @ asdebug.js:10

setTimeout (async)

h @ asdebug.js:10

O.onerror @ asdebug.js:10

error (async)

v @ asdebug.js:10

createRequestTask @ asdebug.js:10

invoke @ asdebug.js:10

r @ asdebug.js:10

invoke @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

X @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

ji @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

i @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

t @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

value @ apihook.js?t=wechat&s=1675004718479&v=0cffbba9918afb1342c18e2fdfb25ef5:1

getAtrList @ index.js? [sm]:235

onLoad @ index.js? [sm]:65

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

p.__callPageLifeTime__ @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Ct @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

It @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Nt.emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

c @ asdebug.js:10

u @ asdebug.js:10

(anonymous) @ asdebug.js:1

f @ asdebug.js:1

g @ asdebug.js:1

(anonymous) @ asdebug.js:1

_ws.onmessage @ asdebug.js:1

Show 20 more frames

WAService.js?t=wechat&s=1675004718479&v=2.6.0:1 request:fail (env: Windows,mp,1.06.2301040; lib: 2.6.0)

Xe @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Nt.emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Wi @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

c @ asdebug.js:10

(anonymous) @ asdebug.js:10

a.emit @ asdebug.js:1

callback @ asdebug.js:10

(anonymous) @ asdebug.js:10

setTimeout (async)

h @ asdebug.js:10

O.onerror @ asdebug.js:10

error (async)

v @ asdebug.js:10

createRequestTask @ asdebug.js:10

invoke @ asdebug.js:10

r @ asdebug.js:10

invoke @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

X @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

ji @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

i @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

t @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

value @ apihook.js?t=wechat&s=1675004718479&v=0cffbba9918afb1342c18e2fdfb25ef5:1

addhits @ util.js? [sm]:101

onLoad @ index.js? [sm]:66

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

p.__callPageLifeTime__ @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Ct @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

It @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

Nt.emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

emit @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

(anonymous) @ WAService.js?t=wechat&s=1675004718479&v=2.6.0:1

c @ asdebug.js:10

u @ asdebug.js:10

(anonymous) @ asdebug.js:1

f @ asdebug.js:1

g @ asdebug.js:1

(anonymous) @ asdebug.js:1

_ws.onmessage @ asdebug.js:1

Show 20 more frames

回答关注问题邀请回答
收藏

5 个回答

  • Schnuffel
    Schnuffel
    2023-02-01

    这是因为微信很早以前就改过 wxml 获取 wx:for 变量的规则,比如以下代码

    // js
    const list = [
      { id: '111', text: '111' },
      { id: '222', text: '222' }
     ]
     
    // wxml
    
    // bad
    <block wx:for="{{ list }}" wx:key="{{ item.id }}">
      
    </block>
    
    // foo
    // wx:key 如果想设置为 item.id 则不能使用双花括号方式,直接使用字符串加属性名即可
    <block wx:for="{{ list }}" wx:key="id">
      
    </block>
    
    2023-02-01
    有用
    回复
  • 十三
    十三
    2023-01-30

    wx:key="{{index}}" does not look like a valid key name (did you mean wx:key="index" ?)

    应该是key的问题: 试试wx:key="{{item.id}" 或者 wx:key="{{*this}}"

    这个看着不对吧<label wx:for="{{sex}}" wx:for-item="item" wx:key="{{item.id}}">

    试试改成<label wx:for="{{sex}}" wx:for="你的数据" wx:key="{{item.id}}">


    2023-01-30
    有用
    回复
  • showms
    showms
    2023-01-30

    wx:key是得item里面的某一个属性名字,不能是动态的,

    比如遍历的数组是

    list=[{id:"1",name:"小红"},{id:"2",name:"小明"}]

    那么wx:key="id"或者wx:key="name"

    2023-01-30
    有用
    回复
  • Jianbo
    Jianbo
    2023-01-30

    试试修改如下

    <label wx:for="{{sex}}" wx:for-item="item" wx:key="{{item.id}}">  改为 <label wx:for="{{sex}}" wx:for-item="item" wx:key="{{id}}">
    
     <view class="addstudy delestudy" bind:tap="goAdd" wx:for="{{studyInfo}}" wx:key="{{index}}"> 修改为  <view class="addstudy delestudy" bind:tap="goAdd" wx:for="{{studyInfo}}" wx:key="{{id}}">
    
    2023-01-30
    有用
    回复
  • 海明溯人
    海明溯人
    2023-01-30

    方便上传console图片查看一下报错吗

    2023-01-30
    有用
    回复
登录 后发表内容