17 lines
461 B
TypeScript
17 lines
461 B
TypeScript
|
import { Message } from 'element-ui'
|
||
|
export default function() {
|
||
|
// 添加值
|
||
|
const addItem = function (data: any, initData = {}) {
|
||
|
data.push(initData)
|
||
|
}
|
||
|
// 删除某组件的item值
|
||
|
const removeItem = function (data: any, index: number, required: boolean = true) {
|
||
|
if (required && data.length == 1) return Message({ message: '值不能少于一项', type: 'warning' })
|
||
|
data.splice(index, 1)
|
||
|
}
|
||
|
return {
|
||
|
addItem,
|
||
|
removeItem
|
||
|
}
|
||
|
}
|