首页 > 解决方案 > 从字符串调用导入的对象

问题描述

我有这个 Vue 插件

import Movement from './Movement'

const PolicyCanPlugin = {
    install(Vue, {store}) {
        Vue.prototype.$policyCan = (model, method) => {
            // how can I call Movement.update_user() using the model(Movement) and method(update_user) variables
        }
    }
}

我想从已经导入的动态模型中调用动态方法(运动)

我想打电话this.$policyCan('Movement', 'update_user')触发Movement.update_user()

标签: javascriptvue.js

解决方案


推荐阅读