我正在将一个 Prop 传递给我的 View ,但是当我在控制台中打印结果时,它会将我发送为未定义,但在 View 中它会向我打印 id,因为未定义我无法执行请求/咨询,这是代码:
export default {
props: ['idVideo'],
data: () => ({
videos: []
}),
created() {
//do something after creating vue instance
this.api = new ApiCanal10({})
this.getRelVideos()
},
methods: {
getRelVideos: function() {
//print in the console
console.log(`video/related/${this.idVideo}`)
}
}
}
如果您能帮助我解决这个问题,我将非常感激。
最佳答案
为了将信息从父级传递给子级,我使用了更新,这是代码:
export default {
updated(){
this.getRelVideos()
},
methods: {
getRelVideos: function() {}
}
}
以这种方式在控制台中显示请求。
关于javascript - Vue.js 中未定义组件 props,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46993197/