<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>
- 发布:2022-11-30 11:29
- 更新:2022-11-30 17:50
- 阅读:89
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 3.6.10
第三方开发者工具版本号: 1.06.2210310
基础库版本号: 无
项目创建方式: HBuilderX
示例代码:
操作步骤:
一直无法获取
一直无法获取
预期结果:
获取 id 值
获取 id 值
实际结果:
找不到
找不到
bug描述:
如下代码,<button type="default" class="cu-btn" @click="daohang(data)">地图</button> daohang无法获取data的值
1 个回复
DCloud_UNI_Anne
未复现此问题,请自查代码并注意要查询的字段已在field中列举【bug优先处理规则】https://ask.dcloud.net.cn/article/38139