Micro-channel applet for custom property value

Write a small program used when the custom properties, specifically to record what

In particular this pit, have to talk about

wxml

<view class='box' bindtap='getValue'>
    <view class='first' data-num="1024" data-name="张三">第一个view</view>
    <view class='second' data-age="2017" data-con="李四">第二个view</view>
</view>

js

data: {
   
  },
  onLoad: function (options) {},
  getValue(e){
        const first = e.target.dataset.name,
        const second = e.target.dataset.conbn
  }

Here is a pit need to say next, I am here to write data-name can be written so data-Name, but when you get in js which must be written in lower case, regardless written in wxml there is a hump or something, get in js the time must be lowercase or to get less, it must be lowercase oh.

Guess you like

Origin www.cnblogs.com/zouwangblog/p/10984904.html