javascript - 求教如何在外部重定义js参数
问题描述
如何在外部重新定义js文件中的data参数?
digg: function(obj, projId, subjId, optId) { data = {’answer’: JSON.stringify(answer),’login’: 1,’source’: 1,’g_tk’: generateToken(getKey()),’format’: ’script’,’callback’: ’parent.AppPlatform.Survey.Digg.ReceiveDiggResult’ }}
问题解答
回答1:data = {’answer’: ’answer’,’login’: 1,’source’: 1,’g_tk’: ’g_tk’,’format’: ’script’,’callback’: function(){}}就可以了,data没有写var。会绑在外面的回答2:
digg: function(obj, projId, subjId, optId) { data = {’answer’: JSON.stringify(answer),’login’: 1,’source’: 1,’g_tk’: generateToken(getKey()),’format’: ’script’,’callback’: ’parent.AppPlatform.Survey.Digg.ReceiveDiggResult’ };}data = {};
就可以了,函数内的data的作用范围只在函数内部有效,所以函数外重新定义data完全不影响函数内部data的操作。
相关文章:
1. spring - mysql中事务是互斥的么?2. python - django 项目的 migrations 目录是否应该提交到 git3. python的文件读写问题?4. python - celery beat 调度如何运行期间动态添加任务?5. python - 多态调用方法时却显示bound method...6. mysql索引的疑问7. mysql group by多个字段8. 取不出SQL得到的当前页9. python小白的基础问题 关于while循环的嵌套10. mysql sql where id in(25,12,87) 结果集如何用按照 25 12 87排序?

网公网安备