Translation of this issue:
Using Baidu map in Modal, error: A cross-origin error was thrown
I have searched the issues of this repository and believe that this is not a duplicate.
Version
3.6.5
Environment
Chrome
Reproduction link
Steps to reproduce
Introduce Baidu map in the entry file index.html
Call Baidu map
componentDidMount = () => {
// var BMap = window.BMap / / take out the BMap object in the window
Var map = new BMap.Map("mapContainer"); // Create a Map instance
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11); // Initialize the map, set the center point coordinates and map level
map.addControl(new BMap.MapTypeControl()); //Add map type control
map.setCurrentCity("Beijing"); // Set the city to display the map. This item must be set.
map.enableScrollWheelZoom(true); //Open mouse wheel zoom
}
Bind id
What is expected?
Use Baidu map component in Modal
What is actually happening?
Use map in Modal, error: ‘Error: A cross-origin error was thrown. React doesn't have access to the actual error object in development.
Going to remove Modal and writing