File tree 2 files changed +21
-7
lines changed
2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 2
2
<div >
3
3
<h1 >Button 示例</h1 >
4
4
<div >
5
- <Button >你好</Button >
5
+ <Button @click = " onClick " >你好</Button >
6
6
</div >
7
7
</div >
8
8
</template >
9
9
<script lang="ts">
10
10
import Button from ' ../lib/Button.vue'
11
11
export default {
12
- components:{ Button }
12
+ components:{ Button },
13
+ setup(){
14
+ const onClick = ()=> {
15
+ console .log (' hi' );
16
+ }
17
+
18
+ return { onClick }
19
+ }
13
20
}
14
21
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <button >
3
- <slot ></slot >
4
- </button >
2
+ <div :size =" size" >
3
+ <button v-bind =" rest" >
4
+ <slot ></slot >
5
+ </button >
6
+ </div >
5
7
</template >
6
8
7
9
<script lang="ts">
8
10
export default {
9
- name: " Button"
10
- }
11
+ inheritAttrs: false ,
12
+ setup(props , context ) {
13
+ // ES6 剩余操作符
14
+ const {size, ... rest} = context .attrs ;
15
+ return {size , rest };
16
+ }
17
+ };
11
18
</script >
12
19
13
20
<style lang="scss" scoped>
You can’t perform that action at this time.
0 commit comments