草庐IT

javascript - 如何在 React App 中嵌入 Google 自定义搜索?

我需要在React应用程序中嵌入一个JS小部件。有办法吗?JS小部件是Google自定义搜索:(function(){varcx='111:xxx';vargcse=document.createElement('script');gcse.type='text/javascript';gcse.async=true;gcse.src='https://cse.google.com/cse.js?cx='+cx;vars=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(gcse,s);})();

javascript - 加载谷歌自定义搜索结果后调用函数?

我基本上需要在搜索结果呈现在我的页面上后运行一些jQuery代码。我可以使用v1代码:Loadinggoogle.load('search','1',{language:'en',style:google.loader.themes.V2_DEFAULT});google.setOnLoadCallback(function(){varcustomSearchOptions={};varorderByOptions={};orderByOptions['keys']=[{label:'Relevance',key:''},{label:'Date',key:'date'}];custo

html - 元素名称 gcse :searchbox-only cannot be represented as XML 1. 0

我在w3验证器中收到以下错误,Line62,Column140:Elementnamegcse:searchbox-onlycannotberepresentedasXML1.0.我正在使用通过此代码添加的网站内的Google搜索栏,请帮忙避免这个错误。谢谢 最佳答案 我发现这个答案隐藏在谷歌文档中:https://developers.google.com/custom-search/docs/element#html5HTML5有效的div标签只要遵守以下准则,您就可以使用HTML5有效的div标签:类属性必须设置为gcse-X