【发布时间】:2021-03-05 13:53:06
【问题描述】:
VUE渲染后如何更新PROPS?
家长
const myProps = [];
window.onmessage = function(data) {
myProps.push(data)
}
new Vue({
el: el || '',
render: h => h(myComponent, {props:{myProps: myProps}}),
});
儿童
<template>...</template>
export default {
props: ['myProps'],
....
}
由于 myComponent 渲染后窗口消息稍后出现.. 在这种情况下没有任何更新,只是得到空数组.. 在这种情况下,收听更新道具的最佳方式是什么?
【问题讨论】:
标签: vue.js vue-component