Javascript 用js显示json
我需要一个项目,使用Json来显示一些特殊效果的图片墙。我决定使用它来轻松创建类。我是json广告新手,我不知道如何显示对象的内容。 这是我的密码:Javascript 用js显示json,javascript,jquery,json,Javascript,Jquery,Json,我需要一个项目,使用Json来显示一些特殊效果的图片墙。我决定使用它来轻松创建类。我是json广告新手,我不知道如何显示对象的内容。 这是我的密码: // RANGES - MOSAIC // Main class Image=[ 'width','height','url','method', { width:'100px', height:'100px', getWidth:function(){return
// RANGES - MOSAIC
// Main class
Image=[
'width','height','url','method',
{
width:'100px',
height:'100px',
getWidth:function(){return this.width},
getHeight:function(){return this.height}
}
].jsonClass();
Product=[
'width','height','url','link','method',
Image,
{
method:'product-pict',
getMethod:function(){return this.method}
}
].jsonClass()
Mood=[
'width','height','url','method',
Image,
{
method:'mood-pict',
getMethod:function(){return this.method}
}
].jsonClass()
Specific=[
'width','height','url','method',
Image,
{
method:'specific-pict',
getMethod:function(){return this.method}
}
].jsonClass()
//Produits
var P1=new Product('100px','100px','http://dev.playboy-fragrance.fr/sites/default/files/slide1_3.png');
//Mood
var M1=new Mood('100px','100px','http://../sites/default/files/mozaic_09.jpg');
var M2=new Mood('100px','100px','http://../sites/default/files/mozaic_11.jpg');
var M3=new Mood('100px','100px','http://../sites/default/files/mozaic_20.jpg');
var M4=new Mood('100px','100px','http://../sites/default/files/mozaic_12.jpg');
var M5=new Mood('100px','100px','http://../sites/default/files/mozaic_08.jpg');
//Specific
var S1=new Specific('100px','100px','http://../sites/default/files/mozaic_09.jpg');
console.log (P1);
console.log (M1);
console.log (S1);
它回来了
constr {width: "100px", height: "100px", url: "http://dev.playboy-fragrance.fr/sites/default/files/slide1_3.png", method: "product-pict", getMethod: function…}
如何使用JS显示它?(Java或jQuery)我想回答它,但它太宽泛了,我给出的答案都不能回答您的具体情况。我投票决定结束,并给你一些建议:1。首先了解什么是javascript,它如何操作DOM;2.如果要进行大量DOM操作,请学习jQuery。在使用一项技术之前,你应该知道你可以用它做什么,以及如何使用它。。。对于这种特殊情况,不要使用
classierjson
。而是学习Javascript。了解Function.prototype是什么,以及如何基于它构建类。例如,要使用javascript创建图像元素,可以调用var myImage=document.createElement('img')
,然后为其分配属性myImage.src=http://..../mosaic.jpg';
然后将其插入需要的位置,例如document.getElementsByTagName(“body”)[0].appendChild(img)代码>好的,谢谢你的指导