2

I have a simple vue.js program with a Form Select BootstrapVue component.

<template>
  <b-card title="Select Service:" style="max-width: 30rem;">
    <div>
      <b-form-select v-model="pdServiceName"
                    class="mb"
                    size="sm"
                    :options="pdServiceNameList"
                    @change="setService">
        <template #first>
          <b-form-select-option :value="null" disabled>
            -- Please select a PD service --
          </b-form-select-option>
        </template>
      </b-form-select>
    </div>
  </b-card>
</template>

<script>
import pdServiceData from '@/service/pd/pdSrvcData';

var vm = new Vue({
  data: {
    pdServiceName: null,
    pdServiceKey: null,
  },
  computed: {
    pdServiceNameList: () => pdServiceData.map((a) => a.service),
  },
  methods: {
    setService() {
      console.log(this.pdServiceName);
      console.log(pdServiceData.find((x) => x.service === this.pdServiceName).key);
      this.pdServiceKey = pdServiceData.find((x) => x.service === this.pdServiceName).key;
    },
  }
});
</script>

pdSrvcData.js:

const pdServiceData = [
  { service: 'srvc_telemetry_staging_alarm', key: 'P6RHJHY' },
  { service: 'srvc_telemetry_wwe_staging_alarm', key: 'PI2UID2' },
];

export { pdServiceData as default };

When I select the options from the Form Select component, the method setService() will be triggered, but I found that the pdServiceKey calculated will be wrong, while if I print the value out to console at the same time, the printouts will be correct: enter image description here

Anyone has any idea why this happens?

1 Answer 1

1

problem is with the dev-tools. as you didn't use 'pdServiceKey' to do anything on the dom, dev-tools ignores the update. if you want to see the change in dev-tools just click on the 'data' property in dev-tools

ref: https://github.com/vuejs/vue-devtools/issues/41#issuecomment-162675083

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I can confirm that the value of pdServiceKey is correct when I refresh the data property in dev-tools.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.