Advertisement
Guest User

javascript

a guest
Aug 21st, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. new Vue({
  2.     el: '#app',
  3.     data: {
  4.         books : [ {
  5.             id: 99,
  6.             title: 'C++ High Performance',
  7.             description: 'Write code that scales across CPU registers, multi-core, and machine clusters',
  8.             authors: 'Viktor Sehr, Björn Andrist',
  9.             publish_year: 2018,
  10.             price: 100000,
  11.             image: 'vue-logo.png'
  12.         }, {id: 100,
  13.             title: 'Mastering Linux Security and Hardening',
  14.             description: 'A comprehensive guide to mastering the art of preventing your Linux system from getting compromised',
  15.             authors: 'Donald A. Tevault',
  16.             publish_year: 2018,
  17.             price: 125000,
  18.             image: 'logo-linux.gif'
  19.         }, {id: 101,
  20.             title: 'Mastering PostgreSQL 10',
  21.             description: 'Master the capabilities of PostgreSQL 10 to efficiently manage and maintain your database',
  22.             authors: 'Hans-Jürgen Schönig',
  23.             publish_year: 2016,
  24.             price: 90000,
  25.             image: 'logo-postgresql.jpg'
  26.         }, {id: 102,
  27.             title: 'Python Programming Blueprints',
  28.             description: 'How to build useful, real-world applications in thePython programming language',
  29.             authors: 'Daniel Furtado, Marcus Pennington',
  30.             publish_year: 2017,
  31.             price: 75000,
  32.             image: 'logo-python.jpg'
  33.         }, ],
  34.         hasiltitle: '',
  35.         tampilSemua: 'true',
  36.         // tampilDetail: 'true'
  37.     },
  38.     methods: {
  39.         findBook: function(event) {
  40.             this.hasiltitle = event.target.value
  41.         },
  42.         // check: function() {
  43.         //     return false;
  44.         // }
  45.     },
  46.     computed: {
  47.         output: function() {
  48.             let h = this.hasiltitle;
  49.            
  50.             let i = this.books.find(function(book) {
  51.                 return book.title === h
  52.             });
  53.             return i;
  54.         }
  55.     },
  56.     watch: {
  57.         output: function() {
  58.             this.tampilSemua = !this.tampilSemua;
  59.             console.log(this.tampilSemua);
  60.         }
  61.     }
  62. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement