mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-04-30 18:59:31 +08:00
update post: code format
This commit is contained in:
parent
031317d662
commit
f69e5b86c5
1 changed files with 23 additions and 4 deletions
|
@ -243,10 +243,29 @@ function toggle(index: number) {
|
||||||
|
|
||||||
> 使用 h 渲染函数来实现一个组件。
|
> 使用 h 渲染函数来实现一个组件。
|
||||||
|
|
||||||
```vue
|
```js
|
||||||
import { defineComponent, h } from 'vue'; export default defineComponent({ name: 'MyButton', props: { disabled: { type: Boolean,
|
import { defineComponent, h } from 'vue'
|
||||||
default: false, }, }, emits: ['custom-click'], setup(props, { emit, slots }) { return () => h( 'button', { disabled:
|
export default defineComponent({
|
||||||
props.disabled, onClick: () => emit('custom-click'), }, slots.default?.() ); }, });
|
name: 'MyButton',
|
||||||
|
props: {
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emits: ['custom-click'],
|
||||||
|
setup(props, { emit, slots }) {
|
||||||
|
return () =>
|
||||||
|
h(
|
||||||
|
'button',
|
||||||
|
{
|
||||||
|
disabled: props.disabled,
|
||||||
|
onClick: () => emit('custom-click')
|
||||||
|
},
|
||||||
|
slots.default?.()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### 树组件
|
### 树组件
|
||||||
|
|
Loading…
Reference in a new issue