uni-app schema2code 生成的代码在微信小程序端取值问题

uni-app schema2code 生成的代码在微信小程序端取值问题

示例代码:

然后执行schema2code,生成的代码中,在detail.vue这个页面中template代码如下(其余代码省略了,主要是显示民族的代码):

<view>
    <text>民族</text>
    <text>{{data.nation_china && data.nation_china[0] && data.nation_china[0].name}}</text>
</view>

在H5页面上可以正常显示,但是微信小程序上就是没有值,这个地方在小程序是undefined,但神奇的是,我单独打印data.nation_chinadata.nation_china[0]data.nation_china[0].name都是有值的,并且结果是对的。也就是如果我换成<text>{{ data.nation_china[0].name}}</text> 就能显示正确的民族。

操作步骤:

使用官方提供的opendb-contacts,添加

"nation_china": {
    "bsonType": "string",
    "title": "民族",
    "trim": "both",
    "enum": {
        "collection": "opendb-nation-china",
        "field": "_id as value, name as text"
    },
    "foreignKey": "opendb-nation-china._id",
    "componentForEdit": {
        "name": "uni-data-picker"
    }
}

预期结果:

在详情detail.vue页面能正常显示 民族

实际结果:

微信小程序端没有显示,结果是undefined

bug描述:

这个bug是接着上一个bug的 【报Bug】schema2code 生成的代码,在微信小程序端报错opendb-contacts.schema.json,并且配置上了nation_china这个字段,具体如下:

"nation_china": {
    "bsonType": "string",
    "title": "民族",
    "trim": "both",
    "enum": {
        "collection": "opendb-nation-china",
        "field": "_id as value, name as text"
    },
    "foreignKey": "opendb-nation-china._id",
    "componentForEdit": {
        "name": "uni-data-picker"
    }
}

更多关于uni-app schema2code 生成的代码在微信小程序端取值问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html

6 回复

没有复现你的问题,贴生成后的完整代码,在看看网络请求返回的数据

更多关于uni-app schema2code 生成的代码在微信小程序端取值问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html


我已经重新上传了附件

回复 kingarthurpu: 贴微信开发者工具网络请求返回的数据

回复 DCloud_uniad_HDX: 已上传仅管理员可见的附件

回复 kingarthurpu: 加我QQ: 87263426

回复 DCloud_uniad_HDX: 已加,

回到顶部