This is the coolest javascript framework ever! So cool to have all the code: HTML, Javascript and CSS all in one place.
Vue Application Basics
index.html is the only HTML vue needs for a Single Page App (SPA)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>survey-spa</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
main.js is the entry point. It is where the Vue instance is created.
// 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/>'
})
The App.vue contains the top level layout for the application.
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Interesting way to put a complete vue directly into an html file.
I just found it online - someone was asking a question and used it as an example.
The template is given an id and referenced by that id in the component.
<div id="app">
<child v-if="dspl"></child>
<input type="button" @click="revert" value="show"/>
</div>
<template id="child">
<div>asdas</div>
</template>
<script>
Vue.component('child', {
template: '#child',
// not sure what this data is for?
data: function () {
return {
internalValue: ''
}
}
});
new Vue({
el: '#app',
data: {
dspl: true,
},
methods: {
revert: function(){
this.dspl = !this.dspl;
}
}
});
</script>