在計算屬性中傳參,然后寫邏輯返回值,需要在封裝一層:
computed: {
函數名() {
return( 參數 ) => { 邏輯 }
}
}
<el-form-item :label="specificationTitle(item)" :prop="item" v-for="item in specificationFrom" :key= "item.id"> <el-input v-modeL="form[item]" :placeholder="`請輸入`+ specificationTitle(item)"></el-input> </el-form- item>
computed: {
specificationTitle () {
return (val) => {
let title = ''
if (val === 'coLour') {
title = '顏色'
} else if (val === 'standard') {
title = '工藝'
} else if (val === 'supplier') {
title='供應商'
} else {
title = '所屬專用'
}
return title
}
}
