const props = defineProps({ dataList: { type: Array, }, onDetail: { type: Function, }, }) const getDetail = (row: any) => { props.onDetail(row) } 提示Uncaught TypeError: props.onDetail is not a function
时间: 2023-05-22 17:04:07 浏览: 137
这个问题可能是因为 onDetail 这个属性没有被传递正确的值或者传进来的不是一个函数导致的。您可以检查一下定义组件时是否正确地传递了该属性以及它的值是否是一个函数类型。另外,您还可以尝试在 getDetail 函数中加上一些调试代码,例如 console.log(props) 来检查传入的属性是否正确。
相关问题
if (form.value.dataList !== undefined && form.value.dataList !== null && form.value.dataList.length > 0) { const totalDeductCommission = countTotal(form.value.refundList, 'deductCommission') // 重新计算退保扣款金额 if (props.statementType === 'Receivables') { const receivablesCommission = form.value.d.commission = countTotal(form.value.dataList, 'totalCommission') - totalDeductCommission // 初始化应收金额 const receivablesGrossProfit = receivablesCommission - countTotal(form.value.dataList, 'rebatePremium') // 初始化毛利金额 if (receivablesCommission === 0 && receivablesGrossProfit === 0) { ElNotification.error('请先完成应收对账后,再次尝试提交!') } } else if (props.statementType === 'Payables') { const payablesCommission = form.value.d.commission = countTotal(form.value.dataList, 'totalChannelCommission') - totalDeductCommission // 初始化应付金额 if (payablesCommission === 0) { ElNotification.error('请先完成应付对账后,再次尝试提交!') } } else { const postData = { policy: form.value.dataList, statement: form.value.d, refund: form.value.refundList } api.post('/statement/saveStatement', postData).then(() => { ElNotification.success('对账单保存成功') resolve() }).catch(() => { }) } } else { ElNotification.error('暂无对账单明细,请添加待对账保单!') }优化这段代码
&& form.value.dataList.length > 0) {
// Perform action
} else {
// Display error message
}
import React, { useState, useCallback } from "react"; import { View } from "@tarojs/components"; import { LgSelepicker } from "lancoo-ui-mobile"; import "../index.scss"; export const Jsx = () => { const dataList = ["全部", "小学", "初中", "高中"]; const [choIndex, setChoIndex] = useState(0); const handleSelect = useCallback((value) => { const _choIndex = dataList.findIndex((item) => item === value); setChoIndex(_choIndex); }, []); return ( <View className="iframe__viewport"> <View className="viewport__title">B款下拉框</View> <View className="viewport__main"> <LgSelepicker type="B" dataList={dataList} choIndex={choIndex} changeSele={handleSelect} /> </View> </View> ); }; 改成类组件写法
import React, { Component } from "react";
import { View } from "@tarojs/components";
import { LgSelepicker } from "lancoo-ui-mobile";
import "../index.scss";
class Jsx extends Component {
constructor(props) {
super(props);
this.state = {
dataList: ["全部", "小学", "初中", "高中"],
choIndex: 0
};
}
handleSelect = (value) => {
const { dataList } = this.state;
const choIndex = dataList.findIndex((item) => item === value);
this.setState({ choIndex });
};
render() {
const { dataList, choIndex } = this.state;
return (
<View className="iframe__viewport">
<View className="viewport__title">B款下拉框</View>
<View className="viewport__main">
<LgSelepicker
type="B"
dataList={dataList}
choIndex={choIndex}
changeSele={this.handleSelect}
/>
</View>
</View>
);
}
}
export default Jsx;
阅读全文