The problem is that I can't pass dynamic Pug variables to Vue component via attributes, if they're of "String" type. Vue considers the string that I'm trying to pass as a name of Vue property.
The problem
template.pug
- var pugVariable = 'John';
my-component(v-bind:name= pugVariable)
*MyComponent.Vue*
export default {
name: 'MyComponent',
props: {
name: {
type: String
}
}
}
I get an error: "Property or method "John" is not defined on the instance but referenced during render.", which means, as far as I understand, that Vue considers string that is in pugVariable as a name of Vue property.
The question
So, the question is: now to persuade Vue to treat this variable as a string?
What I've already tried:
I tried to pass an object literal instead of string, as follows:
my-component(v-bind:name= {value: pugVariable})
It works, but we lose the ability to check the type of passed value, so I don't like this solution.