Skip to content

Commit

Permalink
update 注册方式
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengFeijie committed Oct 25, 2019
1 parent c6f0747 commit 63e1041
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Vue的倒计时组件
<script src="//unpkg.com/vue-timer-countdown"></script>
```

### 注册指令
### 注册组件
1. 全局注册

1. node
Expand All @@ -38,20 +38,20 @@ Vue的倒计时组件

<script>
// 全局注册
Vue.use(vueTimerCountdown, { component: 'timer-countdown' }) // 组件名默认是:timer-countdown
Vue.use(vueTimerCountdown.default, { component: 'timer-countdown' }) // 组件名默认是:timer-countdown
</script>
```
2. 局部注册

1. node

```javascript
import vueTimerCountdown from 'vue-timer-countdown'
import { vueTimerCountdown } from 'vue-timer-countdown'

export default {
components: {
// 局部注册
TimerCountdown: vueTimerCountdown.component
TimerCountdown: vueTimerCountdown
}
}
```
Expand All @@ -65,7 +65,7 @@ Vue的倒计时组件
new Vue({
components: {
// 局部注册
'timer-countdown': vueTimerCountdown.component
'timer-countdown': vueTimerCountdown.vueTimerCountdown
}
})
</script>
Expand Down
4 changes: 2 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

<script>
// 全局注册
// Vue.use(vueTimerCountdown, { component: 'timer-countdown' })
// Vue.use(vueTimerCountdown.default, { component: 'timer-countdown' })

new Vue({
components: {
// 局部注册
'timer-countdown': vueTimerCountdown.component
'timer-countdown': vueTimerCountdown.vueTimerCountdown
},
el: '#app',
data () {
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-timer-countdown.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/vue-timer-countdown.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/vue-timer-countdown.iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
"rollup-plugin-vue": "^5.0.1",
"vue-template-compiler": "^2.6.10"
},
"version": "1.0.1"
"version": "1.1.0"
}
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import vueTimerCountdown from './vue-timer-countdown.vue'

export default {
// 全局注册
const plugin = {
install (Vue, options = {}) {
Vue.component(options.component || 'timer-countdown', vueTimerCountdown)
},
}
}

export {
// 全局注册
plugin as default,

// 局部注册
component: vueTimerCountdown
vueTimerCountdown as vueTimerCountdown
}

0 comments on commit 63e1041

Please sign in to comment.