账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    有关vue activated在子组件中的使用
    64
    0
    页面:base<template> <div class="tab-container"> <h1 style="text-align: center"> 申请{{ form.category }}{{ form.companyType }}入驻 </h1> <div class="form-panel" style="margin-left: 20px;text-align: right;"> <el-button type="info" @click="cancelSave">取消</el-button> <el-button type="warning" @click="transientSave">暂存</el-button> <el-button type="danger" @click="persistSave">保存</el-button> </div> <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card" :before-leave="collectPaneFormData" @tab-click="initPaneData"> <el-tab-pane v-for="item in tabMapOptions" :key="item.key" :label="item.label" :name="item.key"> <keep-alive> <tab-pane :is="item.key" :ref="item.key" :type="item.key" @create="showCreatedTimes" /> <!--<component :is="item.key" :ref="item.key" :type="item.key" @create="showCreatedTimes" />--> </keep-alive> </el-tab-pane> </el-tabs> </div></template>有五个tab-pane, 其中三个子组件中有activated方法。这三个子组件中都有连接跳转到person, 当在person中进行:this.$router.go(-1) // 取消,关闭返回 cancelSubmit() { // 调用全局挂载的方法,关闭当前页 this.$store.dispatch('tagsView/delView', this.$route) this.$router.go(-1) },这时三个子组件的activated方法都会执行吗?如何只让跳转到person中的哪个子组件的activated方法执行,其它两个不执行activated方法
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 玄门剑客 普通会员 1楼

      在Vue中,激活子组件是使用v-on指令和事件监听器来实现的。v-on指令用于在特定事件触发时执行特定的代码,而事件监听器用于在特定事件发生时接收事件并执行相应的操作。

      以下是一个简单的例子:

      ```html

      ```

      在这个例子中,我们在子组件child-component中使用@active属性来监听activated事件。当activated事件触发时,我们调用handleActive方法来设置active属性为true

      在父组件中,我们使用v-on: activated="handleActive"来监听子组件的activated事件。当子组件被激活时,handleActive方法会被调用。

      注意,@active属性在Vue 3中已被弃用,建议使用@on属性和事件监听器。

    更多回答
    网站公告
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部