在wxs中定义的函数传对象的问题
我想在wxs定义的函数中传一个对象类型的值,然而发现一些问题
var testObj1 = { '0': 1, '1': 2}var testObj2 = { 'one': 1, 'two': 2}function test (obj) { console.log(obj) console.log(obj['0']) console.log(JSON.stringify(obj))}module.exports = { testObj1: testObj1, testObj2: testObj2, test: test} |
将以上代码中的testObj在wxml中传入到test
<wxs src="./test.wxs" module="test" />{{test.test(test.testObj1)}} |
第一个log为[object Object]
第二个log为undefined
第三个log为{“nv_0”:1,“nv_1”:2}
第四个log终于得到1
。。。
这个nv_是什么啊,
而且for(var in )竟然也不能用,我要想遍历对象该怎么弄啊,testObj1 还好说,testObj2 不是没办法了吗
