naive-ui/demo/documentation/components/customAdd/zhCN/custom.md

53 lines
851 B
Markdown
Raw Normal View History

2020-03-09 09:29:48 +08:00
# 自定义
```html
2020-03-09 09:29:48 +08:00
<n-custom-add
2020-03-11 16:24:35 +08:00
v-model="test"
title="Add CheckBox"
2020-03-11 16:24:35 +08:00
preset="custom"
:onAdd="add"
>
<template v-slot="slotProps">
<div style="width:100%">
<n-checkbox
v-model="slotProps.item.isCheck"
style="width: 120px;"
/>
<n-input-number
v-model="slotProps.item.num"
/>
<n-input
v-model="slotProps.item.string"
type="input"
size="small"
/>
</div>
</template>
2020-03-09 09:29:48 +08:00
</n-custom-add>
2020-03-09 12:12:31 +08:00
<pre>
{{ JSON.stringify(test,0,2) }}
</pre>
```
```js
export default {
data () {
return {
2020-03-11 16:24:35 +08:00
test: [
{
2020-03-11 16:24:35 +08:00
isCheck: true,
num: 1,
string: 'Test string'
}
]
}
2020-03-11 16:24:35 +08:00
},
methods: {
add (resolve) {
resolve({
isCheck: false,
num: 1,
string: 'Test string'
})
}
}
}
```