Vue js project not loading .env variables

From docs: Note that only NODE_ENV, BASE_URL, and variables that start with VUE_APP_ will be statically embedded into the client bundle with webpack.DefinePlugin. It is to avoid accidentally exposing a private key on the machine that could have the same name. So you need to add VUE_APP_ prefix to your variables.

Vue.js 3 – replace/update reactive object without losing reactivity

Though Boussadjra Brahim’s solution works its not the exact answer to the question. In the sense that reactive data can not be reassigned with = but there is a way to reassign the reactive data. It is Object.assign. Therefore this should work setup(){ const formData = reactive({}) onMounted(() => { fetchData().then((data) => { if (data) … Read more

Reset Vuetify form validation

Example from docs uses: this.$refs.form.reset() Note that while reset() clears validation, it clears input as well. You can follow this issue to see further updates on this. So you can perhaps watch dialog value and reset the form: watch: { dialog() { this.$refs.form.reset() } }

What is the Vuex “context” object?

From the documentation you pointed out you can read: We will see why this context object is not the store instance itself when we introduce Modules later. The main idea of the context object is to abstract the scope of the current Module. If you simply access store.state, it will always be the root state. … Read more

vue.js v-for on two table rows

This is the way you solve it in browsers that support template. <table> <tbody> <template v-for=”item in items”> <tr></tr> <tr class=”detail-row”></tr> </template> </tbody> </table> If you need to support browsers that do not support template, I typically resort to a render function. Here is a working example of both. console.clear() new Vue({ el: “#app”, data: … Read more

Get reference to element in method in Vue.js

You can get the reference to your element in three ways 1. with Method Event Handlers (doc) template: <input type=”text” v-model=”dataField” v-bind:class=”dataFieldClass” /> script: dataFieldClass: function (e) { const element = e.target; } 2. with Inline Handlers (doc) template: <input type=”text” v-model=”dataField” v-bind:class=”dataFieldClass($event, otherArgument)” /> script: dataFieldClass: function (e, otherArgument) { const element = e.target; … Read more

Refused to apply style from ” because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled

The usual reason for this error message is that when the browser tries to load that resource, the server returns an HTML page instead, for example if your router catches unknown paths and displays a default page without a 404 error. Of course that means the path does not return the expected CSS file / … Read more

can’t use template ref on component in vue 3 composition api

I ran into this issue today. The problem is that, when using the <script setup> pattern, none of the declared variables are returned. When you get a ref to the component, it’s just an empty object. The way to get around this is by using defineExpose in the setup block. // Child.vue <template> <div ref=”wrapper”> … Read more