To bridge the access problems encountered by Baidu

Yesterday a colleague on the existing site added code to access Baidu business bridge. Who would have thought a simple introduction of Baidu js strange phenomenon has emerged, click the event all the elements on the page are bound twice, down to the last survey concluded that: Our site uses require.min.js to load the required js, it will search script with a data-main attribute to load data-main designated js file, while js Baidu business bridge is also require functional, will our js file and then loaded once, so leads to the same element twice registered event handlers. I can think of two solutions: 1 modify require.min.js, do not use this data-main attribute, replaced by another, such as data-entry; 2 does not use data-main to load our js,.. but add a script tag to import the js. We chose the latter, after all, is a public require.min.js things, I do not want to increase maintenance costs newcomers.
Published 55 original articles · won praise 39 · views 80000 +

Guess you like

Origin blog.csdn.net/Chinese521/article/details/51150061