-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## 在 TypeScript 中指定组件的类型 | ||
|
||
```html | ||
<script lang="ts"> | ||
// 需要引入这个 | ||
// import { VEditorType } from '@femessage/v-editor' | ||
export default { | ||
mounted() { | ||
(this.$refs.editor as VEditorType).height = 120 | ||
}, | ||
} | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import Vue, {VueConstructor} from 'vue' | ||
|
||
declare module '@femessage/v-editor' { | ||
class FemessageComponent extends Vue { | ||
static install(vue: typeof Vue): void | ||
} | ||
|
||
type CombinedVueInstance< | ||
Instance extends Vue, | ||
Data, | ||
Methods, | ||
Computed, | ||
Props | ||
> = Data & Methods & Computed & Props & Instance | ||
|
||
type ExtendedVue< | ||
Instance extends Vue, | ||
Data, | ||
Methods, | ||
Computed, | ||
Props | ||
> = VueConstructor< | ||
CombinedVueInstance<Instance, Data, Methods, Computed, Props> & Vue | ||
> | ||
|
||
type Combined<Data, Methods, Computed, Props> = Data & | ||
Methods & | ||
Computed & | ||
Props | ||
|
||
type VEditorData = { | ||
editor: any | ||
ClassicEditor: any | ||
isFullScreen: boolean | ||
uploaderAccept: string | ||
previewImageUrl: string | ||
} | ||
|
||
type VEditorMethods = {} | ||
|
||
type VEditorComputed = {} | ||
|
||
type VEditorProps = { | ||
placeholder: string | ||
height: number | string | ||
uploadOptions: object | ||
value: string | ||
editorOptions: object | ||
disabled: boolean | ||
onUploadFail: (status: boolean, error?: any) => void | ||
autosize: object | ||
} | ||
|
||
type VEditor = Combined< | ||
VEditorData, | ||
VEditorMethods, | ||
VEditorComputed, | ||
VEditorProps | ||
> | ||
|
||
export interface VEditorType extends FemessageComponent, VEditor {} | ||
|
||
const VEditorConstruction: ExtendedVue< | ||
Vue, | ||
VEditorData, | ||
VEditorMethods, | ||
VEditorComputed, | ||
VEditorProps | ||
> | ||
|
||
export default VEditorConstruction | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters