I am currently working on a VueJS 3 app. In developer mode everything works fine. But as soon as I build (npm run build) it, I have a place in the app (selectbox whose data comes from an api) where I get an error:
Uncaught ReferenceError: selectedCountry is not defined
The rest of the app works fine.
The location of the compiled JS file. The "isRef(..)" makes trouble!
...($event) => isRef(selectedCountry) ? selectedCountry.value = $event : null)...
^^^^^
Part from the vue file
data() {
return {
countries: [],
cities: [],
selectedCountry: "",
selectedRoute: "",
selectedCity: "",
},
methods: {
async getCountries() {
this.countries = await store.getCountries();
},
async getCities() {
console.log(this.selectedCountry); // <empty string>
const countryId = this.selectedCountry;
this.cities = await store.getCities(countryId);
},
and a part from the html
<select v-model="selectedCountry" @change="getCities">
<option>Select Country</option>
<option v-for="country in countries" :key="country.id"
:value="{countryId: country.id, text: country.name}">
{{ country.name }}
</option>
</select>
I find the error strange because it only happens when I build. Can a helper help me? Thanks in advance!
What I have found
I have found that in the built state, the Select choice is not bound. And i git a <empty string>.