首页 > 解决方案 > 我可以在控制台中看到来自 axios 调用的数据,但它不会在我的视图中呈现(Vuejs)我已经包含了我在控制台中看到的内容(没有错误)

问题描述

这是我要填充的 div 示例。这昨天工作得很好,现在突然间我什么也没看到。我已将我在控制台中看到的内容包含在下面。

   <div class="card_title">Win a {{ prizes.name }}</div>

import axios from 'axios'
    export default {
      name: 'Prizesbyid',
      props: {
        prizeId: String
      },
      data () {
        return {
          prizes: [],
          prize: {},
        }
      },
      mounted () {
        this.getPrizeById()
      },
      methods: {
        getPrizeById () {
          axios.get('http://localhost:3000/prizes/' + this.prizeId).then(response => {
            this.prize = response.data.prize
            this.name = response.data.name
            console.log(response.data)
          })
        }
      }
    }

0: {id: 1, name: "Cordoba C5", description: "The Cordoba C5 Classical Guitar is perfect for any…tension, and low action make it a breeze to play.", image_url: "../assets/c5Cor.png", quantity: 5}
1: {id: 2, name: "Merano MC400 Cello", description: "Established in 2000, Merano have made it their mis… fine examples of professional equipment as well.", image_url: "../assets/cello.png", quantity: 3}
2: {id: 3, name: "Guarnerius del Gesu", description: "A repreduction of the most expensive violin in the…e Akiko Meyers, on loan for the rest of her life.", image_url: "../assets/gesu.png", quantity: 7}
3: {id: 4, name: "Japanese Shamisen", description: "The shamisen or samisen, also sangen, is a three-s…d as a suffix, according to regular sound change.", image_url: "../assets/shamisen.png", quantity: 2}
4: {id: 5, name: "Descant Lacewood Lute", description: "One of the most popular lutes is the Descant Lute.… overall length of the Descant Lute is 25 inches.", image_url: "../assets/lute.png", quantity: 2}
5: {id: 6, name: "Russian Balalaika", description: "The balalaika is a Russian stringed musical instru… and the third string is a perfect fourth higher.", image_url: "../assets/balalaika.png", quantity: 9}
6: {id: 7, name: "Pyrophone", description: "A pyrophone is a musical instrument in which notes…ylindrical glass tubes, creating light and sound.", image_url: "../assets/pyrophone.png", quantity: 3}
length: 7

标签: node.jsdatabaseexpressvue.jsaxios

解决方案


推荐阅读