-
Notifications
You must be signed in to change notification settings - Fork 21
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
3 changed files
with
85 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 { LogViewerType } from '@femessage/log-viewer' | ||
export default { | ||
mounted() { | ||
(this.$refs.logViewer as LogViewerType).autoScroll = false | ||
}, | ||
} | ||
</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,71 @@ | ||
import Vue, {VueConstructor} from 'vue' | ||
|
||
declare module '@femessage/log-viewer' { | ||
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 LogViewerData = { | ||
start: number | ||
scrollStart: number | ||
animate: any | ||
LineWrapper: any | ||
} | ||
|
||
type LogViewerMethods = {} | ||
|
||
type LogViewerComputed = {} | ||
|
||
type LogViewerProps = { | ||
virtualAttrs: object | ||
rowHeight: number | ||
height: number | ||
log: string | ||
loading: boolean | ||
autoScroll: boolean | ||
hasNumber: boolean | ||
scrollDuration: number | ||
} | ||
|
||
type LogViewer = Combined< | ||
LogViewerData, | ||
LogViewerMethods, | ||
LogViewerComputed, | ||
LogViewerProps | ||
> | ||
|
||
export interface LogViewerType extends FemessageComponent, LogViewer {} | ||
|
||
const LogViewerConstruction: ExtendedVue< | ||
Vue, | ||
LogViewerData, | ||
LogViewerMethods, | ||
LogViewerComputed, | ||
LogViewerProps | ||
> | ||
|
||
export default LogViewerConstruction | ||
} |