<template>
<view class="content">
<uni-data-select v-model="value" :localdata="range"></uni-data-select>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
range: [],
}
},
onLoad() {
this.getData();
},
methods: {
monitorApiCall() {
return new Promise((resolve, reject) => {
resolve([{
value: 0,
text: "篮球"
},
{
value: 1,
text: "足球"
},
{
value: 2,
text: "游泳"
},
])
})
},
async getData() {
const result = await this.monitorApiCall();
console.log(result)
this.range = result
}
},
}
</script>
<style lang="scss" scoped>
.content {
padding: 40rpx;
}
</style>
- 发布:2022-12-23 11:00
- 更新:2023-01-16 18:35
- 阅读:3093
产品分类: uniapp/H5
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 12.6
浏览器平台: Chrome
浏览器版本: 107.0.5304.121
项目创建方式: CLI
CLI版本号: 3.0.0-3061420221215001
示例代码:
操作步骤:
<template>
<view class="content">
<uni-data-select v-model="value" :localdata="range"></uni-data-select>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
range: [],
}
},
onLoad() {
this.getData();
},
methods: {
monitorApiCall() {
return new Promise((resolve, reject) => {
resolve([{
value: 0,
text: "篮球"
},
{
value: 1,
text: "足球"
},
{
value: 2,
text: "游泳"
},
])
})
},
async getData() {
const result = await this.monitorApiCall();
console.log(result)
this.range = result
}
},
}
</script>
<style lang="scss" scoped>
.content {
padding: 40rpx;
}
</style>
<template>
<view class="content">
<uni-data-select v-model="value" :localdata="range"></uni-data-select>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
range: [],
}
},
onLoad() {
this.getData();
},
methods: {
monitorApiCall() {
return new Promise((resolve, reject) => {
resolve([{
value: 0,
text: "篮球"
},
{
value: 1,
text: "足球"
},
{
value: 2,
text: "游泳"
},
])
})
},
async getData() {
const result = await this.monitorApiCall();
console.log(result)
this.range = result
}
},
}
</script>
<style lang="scss" scoped>
.content {
padding: 40rpx;
}
</style>
预期结果:
控制台不会报错,并且下拉框有值
控制台不会报错,并且下拉框有值
实际结果:
控制台报错,并且下拉框没有值
控制台报错,并且下拉框没有值
bug描述:
未使用unicloud情况下,也没有传递collection,配置了localdata,控制台报错
目前整个项目,就这一个vue文件使用到了uni-data-select组件。