1

Vue Rendering Problem The back end receives a 200ok signal, but the front end page does not show any results.

    methods:{
      async created() {
          try {
              let response = await axios.get('http://localhost:5000/process')
              this.msg = response.data
              this.msg.$forceUpdate()
          } catch (err) {
              // eslint-disable-next-line
              console.log(err)
          }
      }
      },
};

I've tried many things, such as forced asynchronous update rendering, but the results are still the same.

1
  • 1
    can you change this.message.push(response.data) and then in your template you use v-for to target each obj Commented Nov 13, 2019 at 6:28

1 Answer 1

1

Instead of this.msg.$forceUpdate() use this.$forceUpdate(); and write created() outof methods.

 <template>
        <div class="result" >
        <div  v-bind:style="{ color: `${msg.font_color}`}">
        <p>{{msg.info_text}}</p>
        </div>
        <p> {{msg.rate_adult}}</p>
        <img :src="require(`../../static/dst/${msg.file_name}`)">
        <p>{{msg.part_name}} : {{msg.rate_part}}</p>
        </div>
    </template>
    <script>
    import axios from 'axios';

    export default {
      data() {
          return{
              msg: ""
          }
      },
        methods:{

          },
      async created() {
              try {
                  let response = await axios.get('http://localhost:5000/process')
                 if(response){
                 this.msg = response.data
                  this.$forceUpdate();
               }
              } catch (err) {
                  // eslint-disable-next-line
                  console.log(err)
              }
          }
    };
    </script>
    <style scoped>
    </style>
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the advice. However, it is not rendered yet.
console your msg after assigning response.data
I'm sorry, but can you explain it in more detail? I'm still confused because I'm a vue beginner.
after this this.msg = response.data statement write console.log(this.msg); and post console message here

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.