微信小程序使用data-*向事件内存储对象,但是再js中用dataset取不出来是为什么?

小程序 文章 2022-04-18 09:20 967 0 全屏看文

AI助手支持GPT4.0

微信小程序使用data-*向事件内存储对象,但是再js中用dataset取不出来是为什么?WeChat applet uses data-* to store objects in events, but why can't they be retrieved using dataset in js?

微信小程序使用data-*向事件内存储对象,但是再js中用dataset取不出来是为什么?

如图,我在wxml里用data-*,但是在js里用dataset只能取出来fid,name和type,为什么id取不出来?

As shown in the figure, I use data - * in wxml, but only FID, name and type can be obtained by using dataset in JS. Why can't I get ID?

回答:

空空:

两个wx:for本身就不对 是以第二个wx:for去循环的,想两层循环就写两个view

<view wx:for="{{数据1}}" wx:for-item="item" wx:key="index">

<view wx:for="{{数据2}}" wx:for-item="item1" wx:key="index1"><view>

<view>

那一抹笑😃 穿透阳光:

你代码都有问,两个for循环了,你是不行想重定义index索引

呵呵:

1,为什么view标签有2个for循环?

2,检查for循环的数据里面是否存在id字段

3,你打印的e.currentTarget.dataset里面就没有id的属性

-EOF-

AI助手支持GPT4.0