我有一个json对象,我使用JSON API插件从wordpress加载.当我加载json对象并尝试注销它的部分时,似乎它将每个单个字符视为自己的对象,因此循环返回了几千个对象,所有对象都是单个字符.这是我第一次使用json如此idk,如果我在这里错过了一步.这是我到目前为止使用的代码.
function getProjInfo(theId){
$.ajax({// calling the ajax object of jquery
type: "GET",// we are going to be getting info from this data source
url: 'http://testing.charter21.com/api/get_post/?post_id='+ theId,//the datasource
dataType: "application/json",
success: function(data){
parseJson(data);
}, // what happens when it is successful at loading the XML
error: function(){
alert("error");
}
});
}//end of the function
function parseJson(inData){
postInfo = inData;
$.each(postInfo, function(index, value){
console.log(this);
});
}
Run Code Online (Sandbox Code Playgroud)
json看起来像这样:
{
"status": "ok",
"count": 10,
"count_total": 19,
"pages": 2,
"posts": [
{
"id": 175, …
嘿所有我正在开展一个项目,需要在幻灯片旋转木马中使用乐队,youtube和soundcloud中的嵌入式播放器.
我非常熟悉youtube嵌入js api和soundcloud一个并不复杂,但我似乎找不到任何关于bandcamp的api,不包括获取api密钥和调用api本身.我没有必要这样做.我只是希望能够使用Javascript暂停播放器,如果有人超出幻灯片,那么在幻灯片没有显示时没有播放声音.
想要与bandcamp嵌入小部件进行交互的任何想法或地点?
我正在写一个 HOC 来反应来处理一些滚动功能的繁重工作。我很难让组件渲染。我不断收到此错误:
warning.js?d9a2:33 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Run Code Online (Sandbox Code Playgroud)
我将其精简为 HOC 的最基本部分,但仍然收到此错误。这是我的代码:
这是 HOC 本身:
warning.js?d9a2:33 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
Run Code Online (Sandbox Code Playgroud)
这就是我在我的观点之一中使用它的方式:
import React from 'react';
const withOnScreenMonitor = WrappedComponent => {
return class OnScreenMonitor extends React.Component {
render(){
return (
<WrappedComponent/>
)
}
}
};
export default …Run Code Online (Sandbox Code Playgroud)javascript ×3
carousel ×1
embed ×1
html ×1
html5-audio ×1
jquery ×1
json ×1
reactjs ×1
wordpress ×1