我很好奇将JSON-LD应用到schema.org网站的最佳实践.
如果我有一个页面,Article我也想WebSite在我的页面上定义,我会这样:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://www.example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.example.com/search?&q={query}",
"query-input": "required"
}
}
</script>
<!- … -->
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"author": "John Doe",
"interactionCount": [
"UserTweets:1203",
"UserComments:78"
],
"name": "How to Tie a Reef Knot"
}
</script>
Run Code Online (Sandbox Code Playgroud)
这是对还是错?是否有任何好处或需要将它们合并到相同的脚本或项目数组中?
这是我正在迭代的代码:
<tr th:each="category : ${categories}">
<td th:text="${category.idCategory}"></td>
<td th:text="${category.name}"></td>
<td>
<a th:href="@{'/category/edit/' + ${category.id}}">view</a>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
它指向的URL应该是 /category/edit/<id of the category>
它说无法解析表达式:
<tr th:each="category : ${categories}">
<td th:text="${category.idCategory}"></td>
<td th:text="${category.name}"></td>
<td>
<a th:href="@{'/category/edit/' + ${category.id}}">view</a>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud) 我在Angular应用程序上使用JSPdf,我正在尝试使用JS autotable插件,但我遇到了JS错误
EXCEPTION:未捕获(承诺):TypeError:doc.autoTable不是函数
TypeError:doc.autoTable不是函数
我通过npm安装了jspdf和jspdf-autotable,我确认它们在节点模块中.
我用这种方式导入了两个插件:
import * as jsPDF from 'jspdf'
import * as autoTable from 'jspdf-autotable'
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
private renderPdf():void{
let testcolumns = ["TestCol1", "TestCol2"];
let testrows = [["test item 1", "test item 2"]];
let doc = new jsPDF();
doc.autoTable(testcolumns, testrows);
doc.save('sample.pdf');
}
Run Code Online (Sandbox Code Playgroud)
我可以在这里找到什么或者我可以提供更多代码来帮助确定问题吗?
谢谢!
现在我使用 firebase JS SDK 来使用电话身份验证。我跟着web method.
这是我的代码:
handleClick = () => {
this.state.verify_otp = "flex";
this.state.register = "none";
this.recaptcha = new firebase.auth.RecaptchaVerifier("recaptcha1");
this.number = this.state.phone;
};
Run Code Online (Sandbox Code Playgroud)
。
<View
style={{
alignItems: "center",
justifyContent: "center",
flex: 1,
display: this.state.captcha,
}}
>
<div>
<div id="recaptcha1"></div>
</div>
</View>
Run Code Online (Sandbox Code Playgroud)
是否可以在react-native代码中使用标签?
我有一个文本输入,用于通过 JS 传递值,以使用OData查询参数从 JSON 文件中获取过滤后的名称数据。
如果某人的名字中有撇号,当我传递 URL 时,我会收到错误的请求。
我知道撇号应该通过双引号来转义。我已经尝试过这个,虽然请求没有中断,但它传递时带有两个与数据不匹配的撇号(导致没有结果)。
我的代码大致如下:
JSON
{
"value": [{
"Title": "John O'Smith"
}]
}
Run Code Online (Sandbox Code Playgroud)
超文本标记语言
<input type="text" value="John O'Smith" />
<button>Search</button>
Run Code Online (Sandbox Code Playgroud)
JS
var term = $('input').val();
var searchTerm = term.replace(/'/g, "''");
var serviceURL = "/api/service?&$filter=contains(Title,'" + searchTerm + "')";
$('button').on('click', function(){
$.get( serviceURL, function( data ) {
// Code to display filtered JSON data
});
});
Run Code Online (Sandbox Code Playgroud)
当我serviceURL通过 AJAX 传递上述内容时,URL 将显示为:
/api/service?&$filter=contains(Title,'John O''Smith')
Run Code Online (Sandbox Code Playgroud)
该请求有效,但它带有两个撇号,与我的 JSON 对象不匹配。
如果我按原样传递它 - 没有替换 - …
我的网站上有近 1000 篇文章,这些文章是用 Umbraco 构建的,我想使用文章架构标记来实现它们。
我遇到的问题是大部分内容都是由剃刀动态生成的(例如 @Umbraco.Field("Title") )。我尝试将这些剃刀放入标记的相关代码中,但 Google 的结构化数据测试工具显示所有剃刀均存在错误。
这活一次还能活吗?或者是否有一种解决方法可以标记网站上的多篇文章以从页面上的其他区域提取数据?
感谢您的任何建议。
javascript ×2
schema.org ×2
ajax ×1
angularjs ×1
html5 ×1
java ×1
json ×1
json-ld ×1
jspdf ×1
odata ×1
razor ×1
react-native ×1
seo ×1
spring ×1
spring-boot ×1
spring-el ×1
spring-mvc ×1
umbraco ×1