Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template lang="pug">
- button(@click="on_click(Math.random())") {{value}}
- </template>
- <script>
- export default {
- props: {
- value : {default: 0},
- is_independant : {default: true},
- },
- data(){
- return {
- current_value: this.value // in some cases we might want to clone the value
- }
- },
- watch: {
- value(v){
- this.current_value = v
- },
- },
- methods:{
- on_click(value){
- this.$emit('input', value)
- if(this.is_independant){
- // We only update the internal state if the component is independant
- this.current_value = value
- }
- }
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement