Professional Documents
Culture Documents
VUE JS 2 Basics
VUE JS 2 Basics
Beginning steps :
Html
<p> {{hello}}
</div>
Code :
new Vue({
el : “#app”,
data : {
})
Program 2
<div id=”alok”>
<h1>{{title}}</h1>
</div>
Code
new Vue({
el : ‘#alok’,
data : {
methods : {
changeTitle: function(event)
this.title = event.target.value
Program 3
<div id =”app”>
{{sayHello()}}
</div>
new Vue({
el : ‘#app’,
methods : {
sayHello : function() {
return a+b
}
}
Program 4
<div id=”app”>
{{sayHello()}}
</div>
new Vue({
el : ‘#app’,
data : {
}, methods : {
sayHello : function() {
return this.title
Program 5
<div id=”app”>
new Vue({
el : ‘#app’,
data : {
title: ‘Hello’,
link : ‘https://google.com”
}, methods : {
sayHello() :function() {
return this.title
<div id=”app”>
<h1>{{title}}</h1>
<p>{{sayHello()}}</p>
<a v-bind:href=”link”>Google</a>
<hr>
<p v-html=”finishedLink”></p>
</div>
<div id=”app”>
<p>{{counter}}</p>
<button v-on:click=”increase”>Increase</button>
</div>
new Vue({
el : ‘#app’,
data: {
counter: 0
}, methods : {
Increase:function() {
this.counter++;
})
Example -1
Code
new Vue({
el : '#app',
data : {
title:'Hello Title',
link:'https://google.com',
counter:0,
finishedLink:'<a href="https://www.zapak.com">Zapak</a>'
}, methods : {
sayHello : function(){
this.title='hello'
return this.title
},
increase: function(){
return this.counter++
}
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<h1 v-once>
{{title}}
</h1>
<p>
{{title}}
<p v-html="finishedLink">
Click
</p>
<button v-on:click="increase">
Increase
</button>
<p>
{{counter}}
</p>
</div>
Stephen Grider
html
<div :style="styleTwo"></div>
</div>
</div>
Js
new Vue({
el : '#root',
data : {
styleOne : {},
styleTwo : {}
}, methods : {
onMouseMove(event){
})
function transform(offset) {
const cos = Math.cos(offset);
Css
#root {
height: 100vh;
width: 100vw;
#root div {
position : absolute;
height: 100%;
width: 100%;
background-url: (;')
}
Imperative coding practice : listing out what exactly we need to do
Declarative : Mainly includes laying out the initial states and apply set of rules
Program 2
Vue.js Code
new Vue({
el : '#app',
},
computed : {
},
onInput : function(event) {
})
Html code
<div id="app">
Input:
</div>
<div>
Output
</div>
</div>
html
<div id="app">
</div>
Vue.js
new Vue({
el : '#app',
textInput:''
},
computed : {
identicon : function(){
return jdenticon.toSvg(this.textInput,200)
},
onInput : function(event) {
this.textInput = event.target.value;
},
template :
` <div>
<div>
</div>
<div>
Output
<div v-html="identicon"/>
</div>
</div>`
})