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. notepad+编写的html,打开就是这样了。为什么,大神们2. Mysql取下一条记录3. 求助一个Android控件名称4. javascript 如何下载一个excel文件 ?5. Chrome-org.openqa.selenium.WebDriverException:未知错误:无法在driver.manage()window()maximize();处获得自动化扩展6. mysql federated引擎无法开启7. python 操作mysql如何经量防止自己的程序在之后被恶意注入(说白了就是问一下python防注入的一些要点)8. python3.x - python连oanda的模拟交易api获取json问题第五问9. python 如何打印bytes以16进制输出10. python - 如何使用websocket在网页上动态示实时数据的折线图?

网公网安备