Answer the question
In order to leave comments, you need to log in
How to make your own plugin for Vue2 if the project is in TypeScript?
Hello, I'm trying TS + Vue decided to try to make a global method for Vue.
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
const Plugin = {
install(Vue: any, options?: any) {
Vue.prototype.$Kota = function () {
console.log('Мяу')
}
}
}
Vue.use(Plugin)
new Vue({
router,
store,
render: h => h(App),
}).$mount('#app')
Answer the question
In order to leave comments, you need to log in
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
Vue.config.productionTip = false
declare module 'vue/types/vue' {
interface Vue {
$Kota: () => void
}
}
const Plugin = {
install(Vue: any, options?: any) {
Vue.prototype.$Kota = function () {
console.log('Мяу')
}
}
}
Vue.use(Plugin)
new Vue({
router,
store,
render: h => h(App),
}).$mount('#app')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question