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 tag adds an image in web page?
<div> <img> <span>
<img src="" width="191" height="63" alt="Courses-Web" />
Which of these CSS codes displays the text oblique?
font-style: italic; text-decoration: underline; font-weight: 500;
#id {
  font-style: italic;
Click on the jQuery function used to hide with animation a HTML element.
click() hide() show()
$(document).ready(function() {
  $(".a_class").click(function(){ $(this).hide("slow"); });
Click on the correctly defined function in PHP.
fname function() {} function fname() {} function $fname() {};
function fname($a, $b) {
  echo $a * $b;
Watch Property

Last accessed pages

  1. The Fifth Agreement (16115)
  2. innerHTML in PHP (11019)
  3. sPBM - Simple PHP Backup Manager (1645)
  4. addChild and removeChild (6117)
  5. Create simple Website with PHP (30285)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (630)
  2. Read Excel file data in PHP - PhpExcelReader (421)
  3. PHP-MySQL free course, online tutorials PHP MySQL code (378)
  4. querySelector and querySelectorAll (368)
  5. Create simple Website with PHP (359)