看不懂的UBT
看不懂的UBT
  • 发布:2022-11-30 11:29
  • 更新:2022-11-30 17:50
  • 阅读:89

【报Bug】unicloud-db的 data值 无法通过按钮传递

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 3.6.10

第三方开发者工具版本号: 1.06.2210310

基础库版本号:

项目创建方式: HBuilderX

示例代码:
    <view class="container bg-white" style="height: 100vh;">  
        <view class="btns flex justify-end margin-bottom-lg padding-top-sm margin-right-lg" v-if="abc">  
            <view class="cu-btn solid-bottom text-red" @click="handleDelete">  
                删除  
            </view>  
        </view>  
        <unicloud-db ref="udb" v-slot:default="{data, loading, error, options}" :options="options"  
            :collection="collectionList" field="shop,name,telphone,avatar_file,fenlei,keywords,comment,cun,Geo"  
            :where="queryWhere" :getone="true" :manual="true">  
            <view v-if="error">{{error.message}}</view>  
            <view v-else-if="loading">  
                <uni-load-more :contentText="loadMore" status="loading"></uni-load-more>  
            </view>  
            <view v-else-if="data">  
                <view class="" style="height: 30vh;width: 100vw;">  
                    <image :src="data.avatar_file.url" mode=""></image>  
                </view>  
                <view class="juzhong margin-top-xl">  
                    <view class="" style="display: flex;flex-direction: column;">  
                        <view class="">  
                            <text class="text-xl text-bold">{{data.shop}}</text>  
                        </view>  
                        <view class="text-sm margin-top-sm text-grey juzhong">  
                            <text>主营:{{data.keywords}}</text>  
                        </view>  
                    </view>  

                </view>  
                <view class="cu-list menu">  
                    <view class="cu-item">  
                        <view class="content flex flex-wrap">  
                            <view class="basis-xl">  
                                <text class="text-grey">姓名:{{data.name}}</text>  
                            </view>  
                        </view>  
                    </view>  
                    <view class="cu-item">  
                        <view class="content flex flex-wrap">  
                            <view class="basis-xl">  
                                <text class="text-grey">电话:{{data.telphone}}</text>  
                            </view>  
                        </view>  
                    </view>  
                    <view class="cu-item">  
                        <view class="content flex flex-wrap">  
                            <view class="basis-xl">  
                                <text class="text-grey">地址:{{data.cun}}</text>  
                            </view>  
                            <button type="default" class="cu-btn" @click="daohang(data)">地图</button>  
                        </view>  
                    </view>  
                    <view class="cu-item">  
                        <view class="content flex flex-wrap">  
                            <view class="basis-xl">  
                                <text class="text-grey">类别:{{options.fenlei_valuetotext[data.fenlei]}}</text>  
                            </view>  
                        </view>  
                    </view>  
                    <view class="cu-item">  
                        <view class="content flex flex-wrap">  
                            <view class="basis-xl">  
                                <text class="text-grey">简介:{{data.comment}}</text>  
                            </view>  
                        </view>  
                    </view>  
                </view>  
            </view>  
        </unicloud-db>  
    </view>  
</template>  

<script>  
    // 由schema2code生成,包含校验规则和enum静态数据  
    import {  
        enumConverter  
    } from '../../js_sdk/validator/yz-yaodian.js'  
    const db = uniCloud.database()  

    export default {  
        data() {  
            return {  
                abc: false,  
                queryWhere: '',  
                collectionList: "yz-yaodian",  
                loadMore: {  
                    contentdown: '',  
                    contentrefresh: '',  
                    contentnomore: ''  
                },  
                options: {  
                    // 将scheme enum 属性静态数据中的value转成text  
                    ...enumConverter  
                }  
            }  
        },  
        onLoad(e) {  
            this._id = e.id  
            if (e.alis === 'fenxiang') {  
                this.abc = true  
            }  
        },  
        onReady() {  
            if (this._id) {  
                this.queryWhere = '_id=="' + this._id + '"'  
            }  
        },  
        methods: {  
        async   daohang(e) {  
                console.log(e); //无法获取data的值  
                uni.openLocation({  
                    latitude:e.coordinates[1],  
                    longitude: e.coordinates[0],  
                    success: function() {  
                        console.log('success');  
                    }  
                })  
            },  
            handleUpdate() {  
                // 打开修改页面  
                uni.navigateTo({  
                    url: './edit?id=' + this._id,  
                    events: {  
                        // 监听修改页面成功修改数据后, 刷新当前页面数据  
                        refreshData: () => {  
                            this.$refs.udb.loadData({  
                                clear: true  
                            })  
                        }  
                    }  
                })  
            },  
            handleDelete() {  
                this.$refs.udb.remove(this._id, {  
                    success: (res) => {  
                        // 删除数据成功后跳转到list页面  
                        uni.navigateTo({  
                            url: './list'  
                        })  
                    }  
                })  
            }  
        }  
    }  
</script>  

<style>  
    .container {  
        /* padding: 10px; */  
    }  

    .juzhong {  
        display: flex;  
        justify-content: center;  
        align-items: center;  
    }  

    .btns {  
        /* margin-top: 10px; */  
        /* #ifndef APP-NVUE */  
        display: flex;  
        /* #endif */  
        flex-direction: row;  
    }  

    .btns button {  
        flex: 1;  
    }  

    .btn-delete {  
        margin-left: 10px;  
    }  
</style>

操作步骤:

一直无法获取

预期结果:

获取 id 值

实际结果:

找不到

bug描述:

如下代码,<button type="default" class="cu-btn" @click="daohang(data)">地图</button> daohang无法获取data的值

2022-11-30 11:29 负责人:无 分享
已邀请:
DCloud_UNI_Anne

DCloud_UNI_Anne

要回复问题请先登录注册