Skip to content

Commit

Permalink
修复了typescript编写组件时组件名注册错误
Browse files Browse the repository at this point in the history
  • Loading branch information
isJDongYa committed Dec 16, 2020
1 parent 9d45778 commit b5b2280
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 226 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ follow="follow"
<button class="btn">This is a button in default slot</button>
</jd-moremsg>
```
![example](https://raw.githubusercontent.com/isJDongYa/jd-moremsg/master/examples/assets/imgs/example.gif)
![example](https://raw.githubusercontent.com/isJDongYa/jd-moremsg/master/examples/assets/imgs/header.jpg)



7 changes: 0 additions & 7 deletions examples/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
/*
* @Author: isJDongYa
* @LastEditors: isJDongYa
* @Date: 2020-12-07 19:31:18
* @LastEditTime: 2020-12-08 12:58:26
* @Description:
*/
import Vue from 'vue'
import App from './App.vue'

Expand Down
11 changes: 3 additions & 8 deletions lib/MoreMsg/MoreMsg.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<!--
* @Author: isJDongYa
* @LastEditors: isJDongYa
* @Date: 2020-12-07 16:32:14
* @LastEditTime: 2020-12-08 15:59:36
* @Description: 显示更多信息
-->
<template>
<div
class="more-msg"
Expand Down Expand Up @@ -33,7 +26,9 @@ import { Vue, Component, Prop } from 'vue-property-decorator'
import { Setup } from '@lib/types'
@Component
@Component({
name: 'MoreMsg'
})
export default class MoreMsg extends Vue {
private winWidth:number = document.body.clientWidth;
Expand Down
13 changes: 3 additions & 10 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/*
* @Author: isJDongYa
* @LastEditors: isJDongYa
* @Date: 2020-12-07 20:09:45
* @LastEditTime: 2020-12-08 11:51:47
* @Description:
*/
import { ComponentOptions, VueConstructor } from 'vue';
import MoreMsg from './MoreMsg';
import { ComponentOptions, VueConstructor } from 'vue'
import MoreMsg from './MoreMsg'

const components: {
[index:string]: VueConstructor
Expand All @@ -19,7 +12,7 @@ const install = (Vue:VueConstructor, options?:ComponentOptions<Vue>) => {
for (const key in components) {
if (components.hasOwnProperty(key)) {
const component = components[key];
Vue.component('jd-' + component.name.toLowerCase(), component)
Vue.component('jd-' + component.options.name.toLowerCase(), component)
}
}

Expand Down
11 changes: 11 additions & 0 deletions lib/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ export interface Setup {
width?:string;
height?:string;
background?:string;
}

import Vue from 'vue'

declare module 'vue/types/vue' {
// 声明为 Vue 补充的东西
interface VueConstructor {
options: {
name: string
}
}
}
Loading

0 comments on commit b5b2280

Please sign in to comment.