You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<!--
* @ Author : ch
* @ Date : 2022 - 05 - 09 11 : 31 : 29
* @ LastEditors : ch
* @ LastEditTime : 2022 - 05 - 09 15 : 24 : 30
* @ Description : 按钮 , 每个类型有设置默认高 , 宽度默认随内容变化 , 有特殊大小需要自定义class控制
props
type 固定按钮类型 红色面板 red _panel 红色描边red _line 黄色面板yellow _panel 黄色线条yellow _line 黄色渐变yellow _gradual 灰色grey
radius 是否圆角 true false
disabled 是否禁用 true false
-- >
< template >
< button : class = "`ui-button ${myClass}`" @click ="click" >
< slot > < / slot >
< / button >
< / template >
< script >
export default {
props : {
type : {
type : String ,
default : 'red_panel'
} ,
radius : {
type : String | Boolean ,
default : false
} ,
disabled : {
type : Boolean ,
default : false
}
} ,
computed : {
myClass ( ) {
let classStr = this . type ? ` ui-button__ ${ this . type } ` : '' ;
classStr += this . radius ? ` ui-button__radius ` : '' ;
classStr += this . disabled ? ' ui-button__disabled' : '' ;
return classStr ;
}
} ,
methods : {
click ( ... args ) {
if ( this . disabled ) {
return false ;
}
this . $emit ( 'click' , args ) ;
}
}
}
< / script >
< style lang = "scss" scoped >
. ui - button {
cursor : pointer ;
& _ _red _panel {
background : # FF512B ;
color : # fff ;
height : 46 px ;
font - size : 18 px ;
padding : 0 30 px ;
border : none ;
font - weight : bold ;
}
& _ _red _line {
border : 1 px solid # FF512B ;
height : 44 px ;
font - size : 18 px ;
padding : 0 30 px ;
color : # FF512B ;
}
& _ _yellow _line {
border : 1 px solid # FF512B ;
height : 28 px ;
padding : 0 10 px ;
color : # FF512B ;
}
& _ _yellow _panel {
background : # FF512B ;
height : 30 px ;
padding : 0 10 px ;
border : none ;
color : # fff ;
}
& _ _yellow _gradual {
background : linear - gradient ( 90 deg , # FFA25A 0 % , # FF7F39 100 % ) ;
height : 30 px ;
border : none ;
color : # fff ;
padding : 0 10 px ;
}
& _ _grey {
background : # f5f5f5 ;
border : 1 px solid # ccc ;
height : 28 px ;
padding : 0 10 px ;
}
& _ _radius {
border - radius : 4 px ;
}
& _ _disabled {
opacity : .8 ;
cursor : not - allowed ;
}
}
< / style >