I am trying to import a variable into my Vue component file using the following method:
require('imports-loader?myVar=>{test:12345}!./my-com.vue');
However, I am receiving the error message
[Vue warn]: Error in render function: "ReferenceError: myVar is not defined"
.
While I am aware of using props
, I specifically need to pass a variable.
This is how the content of "my-com.vue" looks like:
<template>
<div>...</div>
</template>
<script>
console.log(myVar); // <--- this triggers the vue warn
export default {
props:['rows'],
...
}
</script>
The import statement can be found here:
module.exports = function(params){
return function(resolve, reject){
resolve({
components:{
'my-com': require('imports-loader?myVar=>{test:12345}!./my-com.vue')
},
...
})
}
}
What am I doing wrong?
How can I successfully import a variable into my Vue component file?
Thank you for your help.