如何使用TypeScript和Vue.js在Visual Studio 2017中启动并运行?

时间:2017-05-03 23:20:05

标签: visual-studio typescript vue.js vuejs2 visual-studio-2017

我试图让 vue.js typescript 一起工作。但是当我编译vue源代码时,我得到了" 未捕获的ReferenceError:未定义的需求"在我的index.html。

这就是我的所作所为:

tsconfig.json

{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"lib": [
  "dom",
  "es5",
  "es2015.promise"
]
},
"include": [
  "scripts/**/*"
],
"exclude": [
  "node_modules",
  "wwwroot"
],
"compileOnSave": true
}

scripts / test.ts (来自vue.js docs

import Vue from 'vue'
import Component from 'vue-class-component'
// The @Component decorator indicates the class is a Vue component
@Component({
  // All component options are allowed in here
  template: '<button @click="onClick">Click!</button>'
})
export default class MyComponent extends Vue {
  // Initial data can be declared as instance properties
  message: string = 'Hello!'
  // Component methods can be declared as instance methods
  onClick(): void {
    window.alert(this.message)
  }
}

的package.json

"dependencies": {
  "vue": "^2.2.6",
  "vue-router": "^2.4.0"
},
"devDependencies": {
  "vue-class-component": "^5.0.1"
}

我没有使用node.js(我不想),只有npm才能下载依赖项。我也在Visual Studio 2017中工作,应用程序在.net核心服务器上运行。

0 个答案:

没有答案