I am very new in VueJS
I have multi-page ASP.NET MVC app where I want to use VueJS (components, 2-way binding, validation, CRUD operations)
Currently using j
I was trying to set up Vue with ASP.NET MVC 5 (.NET 4.5, not Core!) by following a post published above by @Bert, but I have encountered many problems so I found another way:
(WARNING: if you want use vue.js with own components you need install node.js - for npm, webpack - for building bundles and vue-loader - for parsing *.vue files)
npm init -y and hit enter - it should generate packages.json file with dependencies and basic settingsnpm install --save-dev vue-loader vue-template-compilerAdd webpack (globally) and save it in our package.json file:
a) npm install -g webpack
b) npm install –-save-dev webpack
Finally, add Vue.js to project: npm install --save vue
For now, my package.json looks like:
{
"name": "VueExample",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"vue-loader": "^14.2.1",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.2.0"
},
"dependencies": {
"vue": "^2.5.16"
}
}
module.exports = {
entry: './Vue/index.js',
output: {
path: __dirname,
filename: './Vue/dist/bundle.js'
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.vue$/,
exclude: /node_modules/,
loader: 'vue-loader'
}
]
}
};
index.js:
import Vue from 'vue'
import App from './App.vue'
new Vue({
el: '#app',
render: h => h(App)
});
App.vue:
{{msg}}
@{
ViewBag.Title = "Home Page";
}
@section scripts{
}
webpack, hit enter and wait for build your bundle.js which you can find in ~/Vue/dist/bundle.js