add docs
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# CodeEditor 代码编辑器
|
||||
|
||||
带行号、语法高亮与查找替换的代码输入框,基于 textarea 与 Prism 实现。
|
||||
|
||||
## 基础用法
|
||||
|
||||
:::preview 基础用法 || 通过 v-model 绑定内容,实例暴露 openSearch 等方法
|
||||
|
||||
demo-preview=../demos/code-editor/basic.vue
|
||||
|
||||
:::
|
||||
|
||||
## 何时使用
|
||||
|
||||
需要让用户输入或查看结构化代码时使用。组件不做代码校验,只负责输入、高亮与检索。
|
||||
|
||||
## 内容绑定
|
||||
|
||||
`modelValue` 与 `value` 都可作为输入源,`value` 的优先级更高。组件内部会维护一份受控副本,输入时同步抛出 `update:modelValue` 与 `change`。
|
||||
|
||||
## 实例方法
|
||||
|
||||
通过模板引用可以调用组件暴露的方法,例如打开查找栏、定位匹配项或替换内容:
|
||||
|
||||
```ts
|
||||
import type { CodeEditorExpose } from "timi-tdesign-pc";
|
||||
|
||||
const editorRef = ref<CodeEditorExpose>();
|
||||
editorRef.value?.openSearch(true);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
<api-table name="CodeEditor" />
|
||||
Reference in New Issue
Block a user