dauren101
@dauren101
Python, Django ,Vue.js

Передать значение из mounted в 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,
  		
  		
	}
});

Вопрос: как передать значение attrValue2 в procent?
data: {
users: [{ name: '',procent:'' }],
}
  • Вопрос задан
  • 522 просмотра
Решения вопроса 1
this.users[0].procent = this.$refs.div2.getAttribute('data-lastnum-attribute')
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы