自己写的组件,本地编译运行没有报错,但是线上打包报错了,请教下,这里类型哪里有问题了?试了很多,都不成功
e: file://[PackagePath]/wgtRoot/__UNI__6877788/.uniappx/android/src/components/x-popup/x-popup.kt:58:53 Type mismatch: inferred type is Any? but MallProductType was expected
e: file://[PackagePath]/wgtRoot/__UNI__6877788/.uniappx/android/src/components/x-popup/x-popup.kt:63:195 Unresolved reference: goods_name
<template>
<list-view
@scrolltolower="search"
>
<list-item
v-for="(item, index) in list"
:key="index"
@tap.stop="selectItem(item)"
>
<view style="padding: 10px;border-bottom: solid 1px #efefe5;">{{ item.goods_name }}</view>
</list-item>
</list-view>
</template>
<script>
import { MallProductType } from '@/models/index'
export default {
emits: ['select', 'open', 'close', 'search'],
props: {
show: {
type: Boolean,
default: false,
required: true,
},
list: {
type: Array,
default: [] as MallProductType[],
required: true
},
title: {
type: String,
default: '请选择'
}
},
data() {
return {
search_key: '' as String
};
},
methods: {
selectItem(item) {
this.$emit('select', item)
},
open() {
this.$emit('open')
},
close() {
this.$emit('close')
},
search() {
this.$emit('search', this.search_key)
}
}
}
</script>
这是外面调用组件的代码
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1" @refresherrefresh="refresherrefresh" :refresher-enabled="true" :refresher-triggered="refresherState">
<!-- #endif -->
<view class="px-10 mt-10">
<view>
<view v-for="item:PurchaseOrderItemType in purchaseOrder?.purchase_order_items" class="border-bottom-ebeef5">
<view class="flex flex-row">
<view class="px-15 py-15 flex-1 flex flex-row justify-start" @click="openRackSelect(item)">{{ checkGoodsName(item) }}</view>
<view class="px-15 py-15 flex-1 flex flex-row justify-end">
<view v-if="currentPurchaseOrderItem?.id != item.id">{{ item.quantity }}</view>
<view v-if="currentPurchaseOrderItem?.id == item.id">
<view class="input-view">
<input id="quantity-input" :value="currentPurchaseOrderItem?.quantity" @input="changeQuantity" />
</view>
</view>
<view>{{ item.unit }}</view>
</view>
</view>
<view class="flex flex-row items-center">
<view class="px-15 py-15 flex-1 flex flex-row">销售价</view>
<view v-if="currentPurchaseOrderItem?.id != item.id" class="px-15 py-15 flex-1 flex flex-row">{{ item.sales_price }}</view>
<view v-if="currentPurchaseOrderItem?.id == item.id">
<view class="input-view">
<input id="sales-price-input" :value="currentPurchaseOrderItem?.sales_price" @input="changeSalesPrice" />
</view>
</view>
<view class="px-15 py-15 flex-1 flex flex-row justify-end">成本价</view>
<view class="px-15 py-15 flex-1 flex flex-row justify-end">{{ item.cost_price }}</view>
</view>
<view v-if="purchaseOrder?.status == 'pending'" class="px-15 py-15 flex flex-row justify-end">
<view class="mr-10">
<text v-if="currentPurchaseOrderItem?.id != item.id" @click="editItem(item)">编辑</text>
<text v-if="currentPurchaseOrderItem?.id == item.id" @click="updateItem">保存</text>
</view>
<view>
<text @click="destroyItem(item)">删除</text>
</view>
</view>
</view>
</view>
</view>
<x-popup title="请选择商品" :show="productDialogShow" :list="productList" @close="closeProductSelect" @search="searchProduct" @select="selectProductItem"></x-popup>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import { PurchaseOrderType, PurchaseOrderItemType, MallProductType } from '@/models/index'
import { getApi, postApi, putApi, deleteApi } from '@/utils/http/index'
export default {
data() {
return {
productDialogShow: false,
productList: null as MallProductType[] | null,
product_search_key: ''
}
},
onLoad(event : OnLoadOptions) {
this.id = event["id"] ?? "";
this._loadProductList()
},
methods: {
_loadProductList() {
let that = this
getApi(`/v1/mall_products.json`, {} as UTSJSONObject).then(res => {
that.productList = JSON.parse<MallProductType[]>(JSON.stringify((res as UTSJSONObject)['data']))
})
},
openRackSelect(item: PurchaseOrderItemType) {
this.productDialogShow = true
this.currentPurchaseOrderItem = item
},
closeProductSelect() {
this.productDialogShow = false
},
searchProduct(data: string) {
this.product_search_key = data
// this.fetchRackList()
},
selectProductItem(e: PurchaseOrderItemType) {
this.productDialogShow = false
let that = this
putApi(`/v1/purchase_order_items/${this.currentPurchaseOrderItem?.id}/update_goods.json`, {
goods_id: e.id
} as UTSJSONObject).then(res => {
that._loadData()
that.currentPurchaseOrderItem = null
})
}
}
}
</script>
0 个回复