Browse Source

Step 7: computed properties exercise.

Frederic G. MARAND 4 years ago
parent
commit
ecab9175f1
2 changed files with 6 additions and 1 deletions
  1. 1 1
      index.html
  2. 5 0
      main.js

+ 1 - 1
index.html

@@ -25,7 +25,7 @@
         <h2>Available?</h2>
         <p v-cloak v-show="inStock">In stock</p>
         <p v-cloak v-show="!inStock">Out of stock</p>
-        <p v-if="onSale">On sale! Act fast.</p>
+        <p v-cloak v-if="onSale">{{ flashSale }}</p>
 
         <h2>Details</h2>
         <ul>

+ 5 - 0
main.js

@@ -12,6 +12,11 @@ const app = new Vue({
         inStock() {
             return this.variants[this.selectedVariant].variantQuantity > 0;
         },
+        flashSale() {
+            if (this.onSale) {
+                return `Vente flash ${this.product} ${this.brand}. Plus que 10 minutes!`;
+            }
+        },
         title() {
             return [this.brand, this.product].join(' ');
         }