SHARE
TWEET

Untitled

a guest Jun 18th, 2019 205 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template lang="pug">
  2.   button(@click="on_click(Math.random())") {{current_value}}
  3. </template>
  4.  
  5. <script>
  6. export default {
  7.   props: {
  8.     value          : {default: 0},
  9.     is_independant : {default: true},
  10.   },
  11.   data(){
  12.     return {
  13.       current_value: this.value // in some cases we might want to clone the value
  14.     }
  15.   },
  16.   watch: {
  17.     value(v){
  18.       this.current_value = v
  19.     },
  20.   },
  21.   methods:{
  22.     on_click(value){
  23.       this.$emit('input', value)
  24.       if(this.is_independant){
  25.         // We only update the internal state if the component is independant
  26.         this.current_value = value
  27.       }
  28.     }
  29.   }
  30. }
  31. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top