Use JS variable in Vue
21 January 2022
Web
Development
JavaScript
Vue
A simple way to get your (Vanilla) JS variables from an external script and import them into Vue
my_variables.js
export const iconImage = "/waws/get-icon-image?image=";
my_vue.vue
Template
<template>
<img v-bind:src="iconImage" width="64" height="64" />
</template>
Script
<script>
import { iconImage } from "./../../libs/my_variables.js";
export default {
name: "my_vue",
data() {
return {
iconImage: iconImage,
}
},
filters: {},
mounted() {},
props: {},
};
</script>