Javascript 我如何在不编辑插件的情况下覆盖插件的几个参数
想要覆盖插件的几个参数而不编辑它。插件链接我们是否可以添加另一个脚本来覆盖上面的脚本对象参数,例如displayTime为1000,autoStart为false。我尝试了$.extend()。但失败了。我不想在当前插件中进行更改Javascript 我如何在不编辑插件的情况下覆盖插件的几个参数,javascript,jquery,plugins,jquery-plugins,Javascript,Jquery,Plugins,Jquery Plugins,想要覆盖插件的几个参数而不编辑它。插件链接我们是否可以添加另一个脚本来覆盖上面的脚本对象参数,例如displayTime为1000,autoStart为false。我尝试了$.extend()。但失败了。我不想在当前插件中进行更改 <script> (function($,document,undefined) { $.fn.carousel = function(opts) { var options = { 'displayTime': 5000, 'autoSta
<script>
(function($,document,undefined) {
$.fn.carousel = function(opts) {
var options = {
'displayTime': 5000,
'autoStart': true
};
<----code --->
}
</script>
(函数($,文档,未定义){
$.fn.carousel=函数(选项){
变量选项={
“显示时间”:5000,
“自动启动”:true
};
}
您可以用自己的功能替换它:
var oldCarousel = $.fn.carousel; // Need a reference to the original
$.fn.carousel = function(opts) {
var options = {
// set your personal defaults here
};
if (opts) {
$.extend(options, opts);
}
return oldCarousel.call(this, opts);
};
谢谢Mike。但是我不能对现有代码进行任何更改/替换。必须使用外部代码重写此参数code@golekunal88这是外部代码。您可以将其放置在任何文件中。