2022-07-13 02:44:57 +00:00
|
|
|
import Vue, { defineComponent } from '../index'
|
2016-09-21 16:45:40 +00:00
|
|
|
|
2022-05-27 09:26:55 +00:00
|
|
|
declare module '../vue' {
|
2016-09-21 16:45:40 +00:00
|
|
|
// add instance property and method
|
|
|
|
interface Vue {
|
2022-05-27 09:26:55 +00:00
|
|
|
$instanceProperty: string
|
|
|
|
$instanceMethod(): void
|
2016-09-21 16:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add static property and method
|
2017-10-06 18:45:14 +00:00
|
|
|
interface VueConstructor {
|
2022-05-27 09:26:55 +00:00
|
|
|
staticProperty: string
|
|
|
|
staticMethod(): void
|
2016-09-21 16:45:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// augment ComponentOptions
|
2022-05-27 09:26:55 +00:00
|
|
|
declare module '../options' {
|
2016-09-21 16:45:40 +00:00
|
|
|
interface ComponentOptions<V extends Vue> {
|
2022-05-27 09:26:55 +00:00
|
|
|
foo?: string
|
2016-09-21 16:45:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const vm = new Vue({
|
2022-05-27 09:26:55 +00:00
|
|
|
props: ['bar'],
|
2016-09-21 16:45:40 +00:00
|
|
|
data: {
|
|
|
|
a: true
|
|
|
|
},
|
2022-05-27 09:26:55 +00:00
|
|
|
foo: 'foo',
|
2017-10-06 18:45:14 +00:00
|
|
|
methods: {
|
|
|
|
foo() {
|
2022-05-27 09:26:55 +00:00
|
|
|
this.a = false
|
2017-10-06 18:45:14 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
BAR(): string {
|
2022-05-27 09:26:55 +00:00
|
|
|
return this.bar.toUpperCase()
|
2017-10-06 18:45:14 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-27 09:26:55 +00:00
|
|
|
})
|
2016-09-21 16:45:40 +00:00
|
|
|
|
2022-05-27 09:26:55 +00:00
|
|
|
vm.$instanceProperty
|
|
|
|
vm.$instanceMethod()
|
2016-09-21 16:45:40 +00:00
|
|
|
|
2022-05-27 09:26:55 +00:00
|
|
|
Vue.staticProperty
|
|
|
|
Vue.staticMethod()
|
2022-07-13 02:44:57 +00:00
|
|
|
|
|
|
|
defineComponent({
|
|
|
|
mounted() {
|
|
|
|
this.$instanceMethod
|
|
|
|
this.$instanceProperty
|
|
|
|
}
|
|
|
|
})
|