我试图让 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核心服务器上运行。