Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="app">
  <h2>Lifecycle Vue instance</h2>
	<h4>I faza:</h4>
	<p>Pri samom relodovanju stranice se izvrše 4 procesa (pogledaj konzolu):</p>
	<ul>
		<li>"beforeCreate!"</li>
		<li>"created!"</li>
		<li>"beforeMount!"</li>
		<li>"mounted!"</li>
	</ul>
	<h4>II faza:</h4>
  <button @click="promeni">Klikni i promeni tekst ispod <br>(da bi se odradio update DOM-a)</button>
	<p class="update">{{message}}</p>
	<p><strong>Napomena:</strong> <br> Obratite pažnju da se "Updated DOM!" štampa u konzoli samo posle prvog klika na btn, jer Vue koristi Virtual DOM i ažurira "pravi" DOM samo kada treba :)</p>
	<h4>III faza:</h4>
	<button @click="destroy">Ukloni Vue instancu</button>
	<p>Posle klika na dugme "Ukloni Vue instancu" se u konzoli štampa: </p>
	<ul>
		<li>beforeDestroy!</li>
		<li>destroyed!</li>
	</ul>
	<p> Dugme neće reagovati na drugi klik, jer Vue instanca je izbrisana i nema više uticaj na DOM</p>
	<button @click="promeni2">Ovo dugme nema funkciju nakon uklonjene Vue instance</button>
	<p class="update">{{message2}}</p>
</div>

              
            
!

CSS

              
                body {
  font-family: 'Bitter', serif;
}

#app {
  text-align: center;
  margin: 1rem 5rem;
  display: table;
	p, h4{
		text-align: left;
	}
}
.update{
	margin:1rem;
	background-color:#FFC107;
	text-align: center!important;
	padding:1rem
	
}
ul{
	margin: 1rem auto;
	width: 100px;
	padding-left:0;
	li {
		text-align: left;
	}
}

.num {
  color: #AF007E;
}

button {
  font-family: 'Bitter';
  background: #c62735;
  color: white;
  border: 0;
  padding: 5px 15px;
  margin: 0 10px;
  border-radius: 4px;
  outline: 0;
  cursor: pointer;
}

h4 {
  margin: 0 0 15px;
}
              
            
!

JS

              
                new Vue({
  el: '#app',
  data : {
    message: "Tekst za menjanje",
		message2: "Tekst za menjanje"
  },
	 beforeCreate() {
    console.log("beforeCreate!");
  }, 
  created() {
    console.log("created!");
  }, 
  beforeMount() {
    console.log("beforeMount!");
  }, 
  mounted() {
    console.log("mounted!");
  }, 
	updated() {
		 console.log("Updated DOM!");
	},
  beforeDestroy() {
    console.log("beforeDestroy!");
  }, 
  destroyed() {
    console.log("destroyed!");
  },
  methods: {
    promeni : function () {
     this.message = "Promenjen tekst"
    },
		promeni2 : function () {
     this.message2 = "Promenjen tekst"
    },
		destroy : function () {
			this.$destroy();
		}
  }
});
              
            
!
999px

Console