vue 父刷新子_在Vue中父子组件之间的数据传输和子组件中删除操作之后更新父组件刷新当前列表数据...

//定义删除方法 handleDelete()

// 编写删除方法

handleDelete(row) {

let _id = row.id

this.$confirm('是否要删除 ' + row.name + ' ?', '提示', {

dangerouslyUseHTMLString: true,

showCancelButton: false,

confirmButtonText: '确定',

type: 'warning',

center: true

}).then(() => {

this.$axios.post('/api/LampPole/DelLampTypeTypeInfo', { data: { id: _id } }

).then((res) => {

this.$message.success(res.data.msg)

// 通过this.$emit属性传自定义的属性和值给父组件

this.$emit("refresh-item", res.data.code)

}).catch((err) => {

this.$message.error(err)

})

}).catch(e => e);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 2,如果组件数据发生变化,你可以通过以下几种方法来刷新组件的echart: 1. 使用`watch`监听组件数据的变化,并在回调函数手动调用组件刷新方法。例如: ```javascript // 组件 watch: { parentData: function(newValue, oldValue) { // 当组件数据发生变化时,调用组件刷新方法 this.$refs.childComponent.refreshChart(); } } // 组件 methods: { refreshChart() { // 在这里刷新echart } } ``` 2. 使用`$emit`在组件触发一个自定义事件,并在组件监听该事件,然后在监听函数刷新echart。例如: ```javascript // 组件 methods: { updateData() { // 更新组件数据 this.parentData = newData; // 触发自定义事件 this.$emit('data-updated'); } } // 组件 mounted() { // 监听组件触发的自定义事件 this.$parent.$on('data-updated', this.refreshChart); }, beforeDestroy() { // 解除监听 this.$parent.$off('data-updated', this.refreshChart); }, methods: { refreshChart() { // 在这里刷新echart } } ``` 3. 使用`$refs`来直接调用组件的方法。例如: ```javascript // 组件 methods: { updateData() { // 更新组件数据 this.parentData = newData; // 调用组件刷新方法 this.$refs.childComponent.refreshChart(); } } // 组件 methods: { refreshChart() { // 在这里刷新echart } } ``` 以上是几种常见的刷新组件echart的方法,具体选择哪种方法取决于你的项目需求和个人偏好。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值