D
D
Dauren S2019-01-04 09:33:46
Vue.js
Dauren S, 2019-01-04 09:33:46

Pass value from mounted to data Vue.js?

new Vue({
  el: '#app',
  data: {
  	
    users: [{ name: '',procent:'' }],
  
     
  },
  methods: {
      addUser(index) {
      
      	var vm = this
    	const attrValue = this.$refs.div.getAttribute('data-bullshit-attribute');
      const attrValue2 = this.$refs.div2.getAttribute('data-lastnum-attribute');
      	console.log(attrValue2)
      	length=this.users.length
      	length2=length+parseInt(attrValue2);
      	this.users.push({
       	 	name: '',
        	procent: attrValue + '/'+(length+1),
    	});
    },
    deleteUser: function (index) {
      console.log(index);
      console.log(this.finds);
      this.users.splice(index, 1);
      if(index===0)
      this.addUser()
    },
   
   
   
  
  },
 
 	 mounted: function () {
  		const attrValue2 = this.$refs.div2.getAttribute('data-lastnum-attribute');
  		//procent:1,
  		
  		
  }
});

Question: how to pass attrValue2 value to percentage?
data: {
users: [{ name: '',procent:'' }],
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2019-01-04
@dauren101

this.users[0].procent = this.$refs.div2.getAttribute('data-lastnum-attribute')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question