初学者,很简单的功能,但不知道为啥一直搞不掂。
从数据库里获取数据,然后用uni-data-picker展示出来选择后创建订单。
测试在data,return里录入固定数据没问题,直接用collection连接也没问题,但是两个表连接后二级选择不知道如何操作。所以就想着先拿数据再在localdata里绑定使用,但是一直不成功,问题如下图所示。
初学者,很简单的功能,但不知道为啥一直搞不掂。
从数据库里获取数据,然后用uni-data-picker展示出来选择后创建订单。
测试在data,return里录入固定数据没问题,直接用collection连接也没问题,但是两个表连接后二级选择不知道如何操作。所以就想着先拿数据再在localdata里绑定使用,但是一直不成功,问题如下图所示。
喜欢技术的前端 - QQ---445849201
模拟了下数据是可以实现的,你这个data-entry 是个组件吗
<template>
<view class="container">
<uni-section title="数据" type="line">
<view class="uni-px-5 uni-pb-5">
<uni-data-picker placeholder="请选择班级" popup-title="请选择" :localdata="classDataTree" v-model="classValue"></uni-data-picker>
</view>
</uni-section>
</view>
</template>
<script>
import {onMounted} from 'vue'
export default {
data() {
return {
classValue: '1-2',
classDataTree: [],
classDataTree2: [{
text: '一年级',
value: '1-0',
children: [{
text: '1.1班',
value: '1-1'
},
{
text: '1.2班',
value: '1-2'
}
]
},
{
text: '二年级',
value: '2-0',
children: [{
text: '2.1班',
value: '2-1'
},
{
text: '2.2班',
value: '2-2'
}
]
},
{
text: '三年级',
value: '3-0',
disable: true
}
]
};
},
mounted() {
this.classDataTree.push(...this.classDataTree2)
},
methods: {
}
};
</script>
<style>
.container {
/* padding: 0 15px; */
/* #ifndef APP-NVUE */
display: flex;
max-width: 500px;
/* #endif */
flex-direction: column;
}
.title {
font-size: 14px;
font-weight: bold;
margin: 20px 0 5px 0;
}
.input-border {
border: 1px solid #b3e5fc;
border-radius: 5px;
padding: 2px 4px;
}
.input-selected {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
line-height: 2;
}
.data-pickerview {
height: 300px;
border: 1px solid #e5e5e5;
border-radius: 5px;
/* #ifndef APP-NVUE */
overflow: hidden;
/* #endif */
}
</style>
我在uni-app x+vue3中完全复制你的代码报错 [Vue warn]: Invalid prop: type check failed for prop "gettree". Expected Object, got String with value "". \n at <UniDataPicker>\nat <View>\nat <Home>\nat <AsyncComponentWrapper>\nat <PageBody>\nat <Page>\nat <Anonymous>\nat <KeepAlive>\nat <RouterView>\nat <Layout>\nat <App>
只能显示一级菜单
m***@163.com (作者)
感谢回复。先在 data() { return { } } 登记是没有问题的,甚至在 mounted () { }直接录入数据也是没有问题的,只是从unicolud数据库获取数据后,这部份的数据无法渲染。
2023-10-08 15:16