Online Use | English | 更新日志 | 反馈错误/缺漏
npm i landscape-simulator
import LandscapeSimulator from 'landscape-simulator';
LandscapeSimulator.init({
disablePc: false, // default is true
})
It is recommended to place the above initialization code in the head for execution
When using the cdn method, the script tag can be placed in the head
<script auto-simulate='true' src="https://cdn.jsdelivr.net/npm/landscape-simulator"></script>
You can use the property `auto-simulate=true` to control to use auto-on simulation, the default is `false`.
You can use the attribute `disable-pc=false` to control the simulation to be enabled on the pc side. The default is not to enable it on the pc side.
When referenced by cdn, the `LandscapeSimulator` object will be mounted on the window
Initialize the simulator, which will be automatically initialized when referenced by cdn
LandscapeSimulator.init({
disablePc: false, // default is true
})
Add child elements to a rotating container
LandscapeSimulator.appendChild(htmlElement);
Get the emulated later screen size
const size = LandscapeSimulator.getSimulateSize();
Get whether it is currently in a state of simulating a landscape screen
const bool = LandscapeSimulator.isSimulateLandscape();
Listen for changes in the state of the simulated horizontal screen
LandscapeSimulator.onSimulateChange(isSimulate => {
});
const bool = LandscapeSimulator.isEnabled()
const container = LandscapeSimulator.getContainer()