Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从字符串调用导入的对象_Javascript_Vue.js - Fatal编程技术网

Javascript 从字符串调用导入的对象

Javascript 从字符串调用导入的对象,javascript,vue.js,Javascript,Vue.js,我有这个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(up

我有这个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
        }
    }
}
我想从已经导入(移动)的动态模型调用dynamic方法


我想调用
这个。$policyCan('Movement','update_user')
并触发
移动。update_user()

model[method]()将转换为model['update_user'])。这有帮助吗?为什么不使用vuex?@ssBarBee调用
Movement['update_user']()
有效,但变量
model[method]()
@HenriqueVanKlaveren我已经在使用vuex了,但我所有的突变和状态都在存储文件中,我可以编写另一个方法而不使用我的
store.js
文件中的所有方法吗?从“/Movement”导入移动导出默认值({store})=>{const PolicyCanPlugin={store//are accessible here},这样你就可以使用你的store.state、store.getters..}