11<script >
22export default {
33 name: ' zCheckbox' ,
4- props: {
5- value: Boolean ,
6- indeterminate: Boolean ,
7- disabled: Boolean
8- },
9- data () {
10- return {
11- isChecked: this .value
12- }
13- },
14- watch: {
15- value (val ) {
16- this .isChecked = val
17- }
18- },
19- methods: {
20- renderIcon () {
21- if (this .indeterminate ) return < svg width= " 12" height= " 12" >
4+ functional: true ,
5+ render (h , ctx ) {
6+ const { props } = ctx
7+ const renderIcon = function (props ) {
8+ if (props .indeterminate ) return < svg width= " 12" height= " 12" >
229 < rect x= " 0" y= " 0" width= " 12" height= " 12" stroke= " #2080f0" fill= " #2080f0" stroke- width= " 2" / >
2310 < rect x= " 1.5" y= " 5" width= " 9" height= " 2" stroke= " #2080f0" fill= " #fff" stroke- width= " 0" / >
2411 < / svg>
25- if (this . isChecked ) return < svg width= " 12" height= " 12" >
12+ if (props . value ) return < svg width= " 12" height= " 12" >
2613 < rect x= " 0" y= " 0" width= " 12" height= " 12" stroke= " #2080f0" fill= " #2080f0" stroke- width= " 2" / >
2714 < line x1= " 1.5" x2= " 5.5" y1= " 5.5" y2= " 10.5" stroke= " #fff" fill= " transparent" stroke- width= " 1.5" / >
2815 < line x1= " 10.5" x2= " 5" y1= " 2" y2= " 10" stroke= " #fff" fill= " transparent" stroke- width= " 1.5" / >
@@ -31,17 +18,10 @@ export default {
3118 < rect x= " 0" y= " 0" width= " 12" height= " 12" stroke= " #2080f0" fill= " transparent" stroke- width= " 2" / >
3219 < / svg>
3320 }
34- },
35- render () {
36- const { data , root } = this .$parent
37- const { nodeKey } = root
3821 return < div style= {{
39- filter: ` grayscale(${ this .disabled ? 100 : 0 } %)` ,
40- opacity: this .disabled ? 0.7 : 1
41- }} onClick= {e => {
42- this .$emit (' input' , this .isChecked )
43- this .$emit (' change' , e)
44- }}> { this .renderIcon () }< / div>
22+ filter: ` grayscale(${ props .disabled ? 100 : 0 } %)` ,
23+ opacity: props .disabled ? 0.7 : 1
24+ }} onClick= {e => ctx .listeners .click (e)}> {renderIcon (props)}< / div>
4525 }
4626}
4727 </script >
5232 width : 12px ;
5333 height : 12px ;
5434 cursor : pointer ;
35+ margin : 0 0 0 3px ;
5536}
5637svg {
5738 vertical-align : super ;
0 commit comments