D
D
dark_king_132020-03-31 20:14:08
typescript
dark_king_13, 2020-03-31 20:14:08

How to connect Vue to a project inside TypeScript?

I connected Vue to the project inside the JavaScript file and everything worked, but when I renamed index.js to index.ts, everything stopped working. Webpack for working with ts is configured and processes other ts scripts.

index.ts
// Vue.js 
window.Vue = require('vue')
import store from './vue/store/index'

// Vue components (for use in html) 
Vue.component('example-component', require('./vue/components/Example.vue').default)

// Vue init 
const app = new Vue({
  store,
  el: '#app'
})

What needs to be changed in the code to make Vue work?
Mostly a nitpick on the linewindow.Vue = require('vue')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tigran Abrahamyan, 2020-03-31
@dark_king_13

Maybe it's worth importing? Instead of https://vuejs.org/v2/guide/typescript.html
import Vue from 'vue';
window.Vue = require('vue')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question