我有一些简单的代码,其中包含在浏览器中显示网络地图所需的所有html,css /样式和javascript。如果我从本地文件启动它,它将在浏览器中正确打开并显示网络地图。我现在正尝试使用WordPress编辑器/ CMS将代码嵌入页面中。
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="https://js.arcgis.com/3.26/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<script src="https://js.arcgis.com/3.26/"></script>
<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js"></script>
<script>
require(["esri/map", "dojo/domReady!"], function(Map) {
var map;
require(["esri/map", "dojo/domReady!"], function(Map) {
map = new Map("map", {
basemap: "topo",
center: [-122.45, 37.75],
zoom: 13
});
});
});
</script>
<div id="map"></div>
我尝试安装名为'Scripts n Styles'的插件,该插件旨在帮助读取<script>
标签,但仍然显示为空白。这是全新的Word Press安装,因此我不确定是否还需要其他内容或我的代码配置不正确。有什么建议
答案 0 :(得分:1)
最好将<meta>
标签添加到<head>
中,将link
添加到defines
中(尽管WP已经具有此视口标签,因此您可以忽略它)。您可以将其余部分添加到页面本身中(在文本部分-无需插件)。我建议创建一个新模板,请参见:WP Templates
控制台错误显示多个require
。我取出了看似重复的<link rel="stylesheet" href="https://js.arcgis.com/3.26/esri/css/esri.css">
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
<script src="https://js.arcgis.com/3.26/"></script>
<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js"></script>
<script>
var map;
require(["esri/map", "dojo/domReady!"], function(Map) {
map = new Map("map", {
basemap: "topo",
center: [-122.45, 37.75],
zoom: 13
});
});
</script>
<div id="map"></div>
,它在页面上(复制/粘贴)正常工作:
public PizzaService(IPizzaRepo pizzaRepo, IPizzaIngredientsRepo ingredientRepo)
{
_pizzaRepo = pizzaRepo;
_ingredientRepo = ingredientRepo;
}
public async Task SavePizza(PizzaViewModel pizza)
{
using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }))
{
int pizzaRows = await _pizzaRepo.AddEntityAsync(pizza.Pizza);
int ingredientRows = await _ingredientRepo.PutIngredientsOnPizza(
pizza.Pizza.PizzaId,
pizza.Ingredients.Select(x => x.IngredientId).ToArray());
scope.Complete();
}
}
虽然可行,但我仍然建议将其放在模板上。