如何解决VueJS:以编程方式创建的组件发出警告
我在创建组件并在 Nuxt 中动态安装它时遇到了这个问题......这就是我所拥有的
import InfoWindowComponent from './components/GoogleMap/InfoWindow.vue';
.
.
.
let newInfoWindowComponent = Vue.extend(InfoWindowComponent);
this.infoWindowComponentInstance = new newInfoWindowComponent({
parent: this,propsData: {
item: {},}
});
this.infoWindowComponentInstance.$mount();
所以无论我在 Infowindow.vue 中做什么,它都会给我这个错误
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead,use a data or computed property based on the prop's value. Prop being mutated: "item"
我没有在里面的任何地方编辑“item”道具,它只是为了显示目的...不过,我从它制作了一个计算属性,我正在使用它而不是 this.item...但是我'我仍然收到警告... 如果我像这样向组件发送必要的服务,则不会收到警告:
this.infoWindowComponentInstance = new newInfoWindowComponent({
router: this.$router,i18n: this.$i18n,store: this.$store,}
})
;
有人做过这样的事情吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。