File tree Expand file tree Collapse file tree 8 files changed +27
-10
lines changed
examples/sites/demos/pc/app/config-provider Expand file tree Collapse file tree 8 files changed +27
-10
lines changed Original file line number Diff line number Diff line change 33 <tiny-config-provider :design =" design" >
44 <div class =" demo-form" >
55 <tiny-alert type =" warning" description =" 全局配置组件的默认行为" ></tiny-alert >
6- <tiny-form :model =" formData" >
6+ <tiny-form ref = " ruleFormRef " :model =" formData" >
77 <tiny-form-item label =" 年龄" prop =" age" required >
88 <tiny-numeric v-model =" formData.age" ></tiny-numeric >
99 </tiny-form-item >
1010 <tiny-form-item label =" 姓名" prop =" name" required >
1111 <tiny-input v-model =" formData.name" ></tiny-input >
1212 </tiny-form-item >
1313 <tiny-form-item >
14- <tiny-button type =" primary" > 提交 </tiny-button >
14+ <tiny-button @click = " handleSubmitPromise " type =" primary" > 校验 </tiny-button >
1515 </tiny-form-item >
1616 </tiny-form >
1717 </div >
@@ -33,6 +33,7 @@ import {
3333} from ' @opentiny/vue'
3434import { iconWarningTriangle } from ' @opentiny/vue-icon'
3535
36+ const ruleFormRef = ref ()
3637const design = {
3738 name: ' x-design' , // 设计规范名称
3839 version: ' 1.0.0' , // 设计规范版本号
@@ -44,7 +45,8 @@ const design = {
4445 },
4546 Button: {
4647 props: {
47- resetTime: 0
48+ resetTime: 0 ,
49+ round: true
4850 }
4951 },
5052 Alert: {
@@ -72,6 +74,10 @@ const design = {
7274 }
7375}
7476
77+ const handleSubmitPromise = () => {
78+ ruleFormRef .value .validate ()
79+ }
80+
7581const formData = ref ({
7682 name: ' ' ,
7783 age: ' '
Original file line number Diff line number Diff line change 33 <tiny-config-provider :design =" design" >
44 <div class =" demo-form" >
55 <tiny-alert type =" warning" description =" 全局配置组件的默认行为" ></tiny-alert >
6- <tiny-form :model =" formData" >
6+ <tiny-form ref = " ruleFormRef " :model =" formData" >
77 <tiny-form-item label =" 年龄" prop =" age" required >
88 <tiny-numeric v-model =" formData.age" ></tiny-numeric >
99 </tiny-form-item >
1010 <tiny-form-item label =" 姓名" prop =" name" required >
1111 <tiny-input v-model =" formData.name" ></tiny-input >
1212 </tiny-form-item >
1313 <tiny-form-item >
14- <tiny-button type =" primary" > 提交 </tiny-button >
14+ <tiny-button @click = " handleSubmitPromise " type =" primary" > 校验 </tiny-button >
1515 </tiny-form-item >
1616 </tiny-form >
1717 </div >
@@ -55,7 +55,8 @@ export default {
5555 },
5656 Button: {
5757 props: {
58- resetTime: 0
58+ resetTime: 0 ,
59+ round: true
5960 }
6061 },
6162 Alert: {
@@ -87,6 +88,11 @@ export default {
8788 age: ' '
8889 }
8990 }
91+ },
92+ methods: {
93+ handleSubmitPromise () {
94+ this .$refs .ruleFormRef .validate ()
95+ }
9096 }
9197}
9298 </script >
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export default {
1010 } ,
1111 desc : {
1212 'zh-CN' :
13- '可通过<code> design </code>属性设置自定义不同设计规范的图标和逻辑,例如:全局配置 Form 表单组件的必填星号是否默认显示、Button 组件的点击后的禁用时间 。' ,
13+ '可通过<code> design </code>属性设置自定义不同设计规范的图标和逻辑,例如:全局配置 Form 表单组件的必填星号是否默认显示、Button 组件的点击后的禁用时间和是否默认圆角 。' ,
1414 'en-US' :
1515 'Icons and logic for different design specifications can be customized through the <code>design</code> attribute configuration.'
1616 } ,
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export const renderless = (
2626 timer : 0 ,
2727 disabled : props . disabled ,
2828 plain : computed ( ( ) => props . plain || ( parent . buttonGroup || { } ) . plain ) ,
29+ round : computed ( ( ) => props . round ?? designConfig ?. props ?. round ?? false ) ,
2930 formDisabled : computed ( ( ) => ( parent . tinyForm || { } ) . disabled ) ,
3031 buttonDisabled : computed (
3132 ( ) => props . disabled || state . disabled || ( parent . buttonGroup || { } ) . disabled || state . formDisabled
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export interface IButtonState {
77 timer : number
88 disabled : boolean
99 plain : ComputedRef < boolean >
10+ round : ComputedRef < boolean >
1011 formDisabled : ComputedRef < boolean >
1112 buttonDisabled : ComputedRef < boolean >
1213}
Original file line number Diff line number Diff line change @@ -55,7 +55,10 @@ export const buttonProps = {
5555 }
5656 } ,
5757 /** 是否圆角按钮 */
58- round : Boolean ,
58+ round : {
59+ type : Boolean ,
60+ default : undefined
61+ } ,
5962 /** 是否朴素按钮 */
6063 plain : Boolean ,
6164 /** 是否圆形按钮 */
Original file line number Diff line number Diff line change 1515 state.buttonDisabled ? '-disabled' : ''
1616 }`
1717 ),
18- gcls(round ? 'is-round' : 'no-round'),
18+ gcls(state. round ? 'is-round' : 'no-round'),
1919 gcls(circle ? 'is-circle' : 'no-circle'),
2020 gcls({ 'is-border': circle || !(type === 'text' || icon) }),
2121 gcls({ 'button-link': href }),
Original file line number Diff line number Diff line change 2424 'is-loading': loading,
2525 'is-plain': state.plain,
2626 'is-ghost': ghost,
27- 'is-round': round,
27+ 'is-round': state. round,
2828 'is-circle': circle,
2929 'is-icon': icon && !loading && (text || slots.default),
3030 'is-only-icon': icon && !loading && !(text || slots.default)
You can’t perform that action at this time.
0 commit comments