少數html頁面中使用vuejs 2我有一個ASP.Net核心MVC與剃鬚刀視圖,使用VueJs2時,它需要更復雜。如何使用打字稿和ASP.Net核心
我想每個視圖都有一個js文件。
我的文件夾結構是這樣的:
├ Controllers\HomeController.cs (with actions Index & Details)
├ Scripts\Home\index.ts
├ Scripts\Home\details.ts
├ Views\Home\Index.cshtml
├ Views\Home\Details.csthml
├ wwwroot\lib\vue
├ wwwroot\js\Home\index.js (generated with typescript)
├ wwwroot\js\Home\details.js (generated with typescript)
├ tsconfig.json
這裏是我的tsconfig.json
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outDir": "wwwroot/js",
"rootDir": "Scripts",
"allowSyntheticDefaultImports": true,
"lib": [
"dom",
"es5",
"es2015.promise"
]
},
"include": [
"wwwroot/lib/vue/typings",
"Scripts"
],
"compileOnSave": true
}
我index.ts文件
import Vue from 'vue'
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
而生成的文件:
"use strict";
var vue_1 = require("vue");
var app = new vue_1.default({
el: '#app',
data: {
message: 'Hello Vue!'
}
});
//# sourceMappingURL=index.js.map
在我的Index.cshtml中我加載了js文件,但是我有這個需要的指令在我的瀏覽器中不起作用。
如何讓這個js文件在瀏覽器中工作?
」有這種需求指令,在我的瀏覽器中不起作用。「 - 你會得到什麼錯誤? –