@@ -22,7 +22,6 @@ This project references the following projects, and I would like to express my g
2222- Github Code Diff
2323
2424## Contents
25-
2625- [ Install] ( #Install )
2726- [ Getting started] ( #Getting-started )
2827 - [ Vue3] ( #Vue3 )
@@ -58,6 +57,24 @@ pnpm add @vue/composition-api
5857
5958### Vue3
6059
60+ #### Register locally
61+ > Recommend using local registration for better tree-shaking support.
62+ ``` vue
63+ <script setup>
64+ import { CodeDiff } from 'v-code-diff'
65+ </script>
66+
67+ <template>
68+ <div>
69+ <CodeDiff
70+ old-string="12345"
71+ new-string="3456"
72+ output-format="side-by-side"
73+ />
74+ </div>
75+ </template>
76+ ```
77+
6178#### Register globally
6279
6380``` ts
8198</template>
8299```
83100
84- #### Register locally
85-
86- Not recommended, but the relevant capabilities are retained to facilitate migration for 0.x users.
87-
88101### Vue2
89102
90- #### Register globally
103+ #### Register locally
104+ > > Recommend using local registration for better tree-shaking support.
105+ ``` vue
106+ <script>
107+ import { CodeDiff } from 'v-code-diff'
108+ export default {
109+ components: {
110+ CodeDiff
111+ }
112+ }
113+ </script>
91114
115+ <template>
116+ <div>
117+ <CodeDiff
118+ old-string="12345"
119+ new-string="3456"
120+ output-format="side-by-side"
121+ />
122+ </div>
123+ </template>
124+ ```
125+ #### Register globally
92126``` ts
93127import Vue from ' vue'
94128import CodeDiff from ' v-code-diff'
95129
96130Vue .use (CodeDiff )
97131```
98132
99- #### Register locally
100-
101- Not recommended, but the relevant capabilities are retained to facilitate migration for 0.x users.
102-
103133## Demo
104134
105135| | npm | cdn |
@@ -160,13 +190,40 @@ If the language you need is not included, you can manually import the relevant l
160190``` shell
161191pnpm add highlight.js
162192```
193+ #### Register locally
194+ > Recommend using local registration for better tree-shaking support.
195+ ``` vue
196+ <script>
197+ import { CodeDiff, hljs } from 'v-code-diff'
198+ import c from 'highlight.js/lib/languages/c'
199+ // Extend C language
200+ hljs.registerLanguage('c', c)
201+ export default {
202+ components: {
203+ CodeDiff,
204+ }
205+ }
206+ </script>
163207
208+ <template>
209+ <div>
210+ <CodeDiff
211+ old-string="#include <stdio.h>"
212+ new-string="#include <stdio.h>\nint a = 1;"
213+ output-format="side-by-side"
214+ language="c"
215+ />
216+ </div>
217+ </template>
218+ ```
219+
220+ #### Register globally
164221``` typescript
165- import CodeDiff from ' v-code-diff' ;
222+ import CodeDiff from ' v-code-diff'
166223// Extend C language
167- import c from ' highlight.js/lib/languages/c' ;
224+ import c from ' highlight.js/lib/languages/c'
168225
169- CodeDiff .hljs .registerLanguage (' c' , c );
226+ CodeDiff .hljs .registerLanguage (' c' , c )
170227```
171228
172229## Migrate from 0.x version
0 commit comments