I have a method and puted property of same name, when I try to access these, I am getting following error:
vue.min.js:6 Uncaught TypeError: doubleAge is not a function(…)
Following is the simplified code from jsfiddle:
var demo = new Vue({
el: '#demo',
data: function(){
return {
age: ''
};
},
puted: {
doubleAge: function () {
return 2*this.age
}
},
methods: {
doubleAge: function () {
return 'this is from method'
}
}
})
I have doubleAge
as puted property and method both. Is there some other way to call the method in this case, how to make this work?
I have a method and puted property of same name, when I try to access these, I am getting following error:
vue.min.js:6 Uncaught TypeError: doubleAge is not a function(…)
Following is the simplified code from jsfiddle:
var demo = new Vue({
el: '#demo',
data: function(){
return {
age: ''
};
},
puted: {
doubleAge: function () {
return 2*this.age
}
},
methods: {
doubleAge: function () {
return 'this is from method'
}
}
})
I have doubleAge
as puted property and method both. Is there some other way to call the method in this case, how to make this work?
- An object property can only name one thing. Why don't you give them different names? – Barmar Commented Dec 16, 2016 at 2:37
- @Barmar I had a case where some places I wanted a variable from puted property and some places I want to get it from backend, may be I can rename it to latestMyVar if it's not possible. – Saurabh Commented Dec 16, 2016 at 2:45
- I tried using vue.js (unminified version), but it didn't give any more descriptive error in this case. Usually the unminified version provides more info than the production version, which you can consider for jsFiddle and development env. – Mani Jagadeesan Commented Dec 16, 2016 at 2:59
1 Answer
Reset to default 8No It's not possible, every property on an object must be uniquely named