vue use of experience working in some of the key points ---

1, custom components using v-for loop, preferably together with additional multi the bind-V: Key = "items_name", which is a special use: Key, instead of the normal: Properties

Example: <Uiroom> loop v-bind = "items" of an object is passed in common, V the bind-: Key special key-cycle

< Uiroom
v-for="items in Roomsmsg"
v-bind:key="items"
v-bind="items"
@click.native="OnUiRoomClick(items.name)"
></ Uiroom>
 
data () {
  return {
      pagetitle: 'Overview Information',
      Roomsmsg: [
        {
          name: '1001'
        },
        {
          name: '1002'
        },
        {
          name: '1003'
        }
      ]
    }
},
 
 
2, for simplicity generic click event, you can bind components to the root element of the native DOM events, plus .native. For example  @ click.native
 

Guess you like

Origin www.cnblogs.com/qinlongqiang/p/11534185.html