?
于2023-10-27 17:57:17发布
44
有时候后端的接口的某个变量返回的是一个数字类型,但是双向绑定的时候需要
<el-input
:value="d.data.currentNumber? '' + d.data.currentNumber : ''"
:onUpdateValue="(val) => {d.data.currentNumber = val}"
/>
<el-switch v-model="computedSwitch" />
// 数据
const ruleForm = ref({
billHeaderType: '0', // 发票抬头类型 0->企业;1->个人;
billHeader: '', // 发票抬头
billTaxId: '', // 纳税人识别号
billAddress: '', // 开票地址
billPhone: '', // 公司注册电话
billEmail: '', // 工作邮箱
billBank: '', // 开户银行
billBankAccount: '', // billBankAccount
isDefault: 1, // 是否默认 0->否;1->是; todo!
userName: '', // 个人名称
});
// el-switch用
const computedSwitch = computed({
get() {
return ruleForm.value.isDefault === 1;
},
set(newValue) {
ruleForm.value.isDefault = newValue ? 1 : 0;
}
});