File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,14 @@ import { defineComponent } from 'vue'
2
2
import CodeBox from '../../shared/devui-codebox/devui-codebox'
3
3
import ButtonPrimary from './primary/primary'
4
4
import ButtonCommon from './common/common'
5
+ import PrimaryCode from './primary/primary.tsx?raw'
6
+ import CommonCode from './common/common.tsx?raw'
5
7
6
8
export default defineComponent ( {
7
9
name : 'd-button-demo' ,
8
10
setup ( ) {
9
- const primarySource : any [ ] = [ ] ;
10
- const commonSource : any [ ] = [ ] ;
11
+ const primarySource : any [ ] = [ { title : 'TSX' , language : 'TSX' , code : PrimaryCode } ] ;
12
+ const commonSource : any [ ] = [ { title : 'TSX' , language : 'TSX' , code : CommonCode } ] ;
11
13
return ( ) => {
12
14
return < div class = "demo-container" >
13
15
< div class = "demo-example" >
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ export default defineComponent({
86
86
{ ! _copied . value ? < CopyIcon > </ CopyIcon > : < CopiedIcon > </ CopiedIcon > }
87
87
</ span >
88
88
</ div >
89
- < DevuiHighlight > </ DevuiHighlight >
89
+ < DevuiHighlight code = { item . code . default || item . code } language = { item . language } > </ DevuiHighlight >
90
90
</ div >
91
91
</ DevuiTab >
92
92
)
Original file line number Diff line number Diff line change @@ -3,10 +3,17 @@ import { defineComponent } from 'vue'
3
3
export default defineComponent ( {
4
4
name : 'd-highlight' ,
5
5
props : {
6
+ code : String ,
7
+ language : String
6
8
} ,
7
9
setup ( props , ctx ) {
8
10
return ( ) => {
9
- return < div > devui-highlight</ div >
11
+ return (
12
+ < pre class = { `language-${ props . language } ` } >
13
+ { /* 暂做处理避免tsx语法被解析为html标签 */ }
14
+ < code innerHTML = { props . code ?. replace ( / ( < ) / g, '<' ) } > </ code >
15
+ </ pre >
16
+ )
10
17
}
11
18
}
12
19
} )
You can’t perform that action at this time.
0 commit comments