I have something like this as a component:
Vue.component
(
'mycomp',
{
props : ['c'],
data : function()
{
return { var1 : true, var2 : [] }
},
template : `<div v-html='func1(c.id)'></div>`,
methods :
{
func1(id)
{
// ...
return func2(id);
},
func2(id)
{
var someRegExp = /blah/ig;
return id.replace(someRegExp, function(capture)
{
//...
if(cond) this.var2.push(id);
return `<a href='/post/${id}'></a>`
});
}
}
}
);
The error I get here would be:
TypeError: "this.var2 is undefined" and the source of the error points to func2. What am I doing wrong ?