javascript - 从字符串调用导入的对象
问题描述
我有这个 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()
解决方案
推荐阅读
- python - 尝试在 for 循环中进行数学运算时出现意外行为
- simulation - 在 Anylogic 中,我想存储 n 个使用 switch 语句排序的“产品”,然后使用 AGV 移动它们
- javascript - 为什么 x 的值没有更新?代码有什么问题吗?我是 javascript 新手
- python - 如何展平 Pandas DataFrame 列表列中的分隔字符串?
- c# - 使用隐藏字段时 viewModel 为空
- arrays - 在 C 中存储多个字符串
- python - 如何创建一个脚本来对多个列表中的值进行排序并将它们添加到空列表中?
- javascript - 基于窗口本地存储的倒计时定时器
- spring-boot - Spring Boot REST API 删除重复的响应体
- printing - 在 Fortran 中打印带有字符和数字的字符串时出错