Cài đặt (ok)
https://vi.vuejs.org/v2/guide/installation.html
$ npm install --global vue-cli #cài đặt vue-cli
$ vue init webpack my-vue # tạo một dự án mới với template "webpack"
$ cd my-vue
$ npm run dev #chạy server

C:\xampp\htdocs\html\src\main.js
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
C:\xampp\htdocs\html\src\App.vue
<template>
<div id="app">
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
C:\xampp\htdocs\html\src\router\index.js
import Vue from 'vue';
import Router from 'vue-router';
import HelloWorld from '@/components/HelloWorld';
Vue.use(Router);
export default new Router({
routes: [
{
path: '/',
name: 'HelloWorld',
component: HelloWorld
}
]
})
C:\xampp\htdocs\html\src\components\HelloWorld.vue
<template>
<div class="hello">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
PreviousEasy 4 Steps: Auto Deploy Vue.js App on Heroku (ok)NextCách truy câp js thuần trong Vuejs 😒😒😒
Last updated
Was this helpful?