uniapp 微信小程序 picker下拉菜单数据回显

<template>
	<view class="absorptive-type">
		<view>所属企业:</view>
		<view>
			<block v-for="(item, index) in companyList" :key="index">
				<text v-if="item.dictValue === info.transporterId">{
    
    {
    
    item.dictLabel}}</text>
			</block>
		</view>
	</view>
</template>
data() {
    
    
	return {
    
    
		//companyList: [],// 企业列表(接口返回)
		// 企业列表(模拟数据)
		companyList: [
			{
    
    
				"dictValue: ": "0",
				"dictLabel: ": "清表"
			},{
    
    
				"dictValue: ": "1",
				"dictLabel: ": "拆迁"
			},{
    
    
				"dictValue: ": "2",
				"dictLabel: ": "轨道"
			},
		],
		info:{
    
    
			transporterId:""//返回的数据
		}
	}
},
onLoad: function(options) {
    
    
	this.getCompanyList()
},
//获取企业列表
getCompanyList: function() {
    
    
	uni.showLoading();
	var params = {
    
    
		url: "/transporterList",
		method: "GET",
		data: {
    
    },
		callBack: res => {
    
    
			uni.hideLoading()
			this.companyList = res.rows
		}
	};
	http.request(params);
}

猜你喜欢

转载自blog.csdn.net/maoge_666/article/details/132145100