Vuejs Course

A watcher allows you to "watch" a property of the component data, and run a function when that property value changes.
In the watch object add a method with the same name as the property data you want to "watch".

var vm = new Vue({
 el: 'css_selector',
 data: {
 prop_name: 'value'
 watch: {
 prop_name: function(newVal, oldVal{
 //code and value to return

The function assigned to watch.prop_name can optionally accept 2 parameters. The first is the new property value (newVal). The second is the old property value.

Here is a practical example with the watch property in vue.js. Add the diameter of a circle into an input field, then it is displayed the perimeter and area:
<div id='demo'>
 Diameter circle: <input type='number' value='0' v-model='diameter'/><br>
 Perimeter: {{perimeter}}<br>
 Area: {{area}}

var vm = new Vue({
 data: {
 diameter: 0,
 watch: {
 diameter: function(val){
 this.perimeter = 3.14*val;
 this.area = 3.14*(val*val)/4;

Daily Test with Code Example

Which attribute is used in <img> tag for the address of the image?
href src rel
<img src="" width="191" height="63" alt="Courses-Web" />
Which CSS code hides the element on page?
display: none; display: inline; position: relative;
#id {
  display: none;
What instruction stops the execution of a while() or for() statement?
continue prompt() break
for(var i = 0; i< 8; i++) {
  if(i > 1) break;
Indicate the function that can create a constant.
define() include() defined()
define("CONSTANT_NAME", "value");
Watch Property

Last accessed pages

  1. Pencil and Pen Tools (1627)
  2. Display multiple groups of images (3489)
  3. Script comments with pagination (3655)
  4. SSEP - Site Search Engine PHP-Ajax (9264)
  5. The School for Gods (1500)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (710)
  2. Read Excel file data in PHP - PhpExcelReader (401)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (387)
  4. HTML Course - Free Lessons (356)
  5. JavaScript Course - Free lessons (337)