Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: 增加向js文件传递变量的方法 #143

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

cshaptx4869
Copy link
Contributor

拿 EasyAmin 中的文件举例:

  • Admin.php 控制中调用 $this->setJsVariables('statusOptions', [0=>'禁用', 1=>'启用']); 向 admin.js传递 js 变量;
  • admin.js 文件中调用 $variables.statusOptions 就可以获取后 php 传递过来的 js 变量;
  • 举个栗子比如在 admin.js 的 table 的 selectList 参数就可以不用写死了。 {field: 'status', title: '状态', width: 85, search: 'select', selectList: {0: '禁用', 1: '启用'}, templet: ea.table.switch} 改为 {field: 'status', title: '状态', width: 85, search: 'select', selectList: $variables.statusOptions, templet: ea.table.switch},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant