将值传递给动能js

时间:2014-05-29 09:28:30

标签: javascript php wordpress kineticjs

var data = {
"images": [
    "img/image1.jpg",
    "img/image2.jpg",
    "img/image3.jpg"
],
"captions":[
    [
        "This is Sample Caption For Image 1",
        "Also This is Sample Caption For Image 1"
    ],
    [
        "This is Sample Caption For Image 2"
    ],
    [
        "This is Sample Caption For Image 3",
        "Also This is Sample Caption For Image 3",
        "And So Does This !"
    ]
]
};

var canvasWidth;
var canvasHeight;

var stage;
var layer = new Kinetic.Layer();

function init(config) { }init({"container":"container"});

在上面的kinetic中,其中var data = image:[],caption:[]是使用我想动态使用的图像来自canvas.php,在canvas.php我们有php代码,现在我必须通过图像路径和字幕到js以上

1 个答案:

答案 0 :(得分:0)

试试这个:

<script>var img_path = '<?php echo $img_path?>'</script>

将此作为保存您的值的全局变量。

现在您可以将此变量用于kinetic.js