gpt4 book ai didi

javascript - 无法包含 JavaScript

转载 作者:行者123 更新时间:2023-12-02 19:05:22 25 4
gpt4 key购买 nike

我正在尝试实现 Supersized我的 Yii 项目的 slider 。为了实现我必须在 View 中实现一些javascript。所以我决定采用 registerscript 方法。但我认为我无法初始化图像的目录位置。你能帮我吗

我的代码是

<?php   

$script= <<<EOD
jQuery(function($){
$.supersized({
slide_interval :7000, // Length between transitions
transition :1, // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
transition_speed :1000, // Speed of transition
slide_links :'blank',// Individual links for each slide (Options: false, 'num', 'name', 'blank')
slides :[// Slideshow Images
$directory = Yii::getPathOfAlias('webroot').'/uploads/';
$images = glob($directory . "*.{jpg,JPG,jpeg,JPEG,png,PNG}", GLOB_BRACE);
foreach($images as $image)
echo "{image : 'http://localhost/uploads/" . $image . "', title : '" .$image . "'},";
]
});
});
EOD;
Yii::app()->clientScript->registerScript('customFnc', $script, CClientScript::POS_READY);?>

最佳答案

试试这个方法..

<script>
jQuery(function($){
$.supersized({
slide_interval :7000, // Length between transitions
transition :1, // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
transition_speed :1000, // Speed of transition
slide_links :'blank',// Individual links for each slide (Options: false, 'num', 'name', 'blank')
slides :[// Slideshow Images
<?php
$directory = Yii::getPathOfAlias('webroot').'/uploads/';
$images = glob($directory . "*.{jpg,JPG,jpeg,JPEG,png,PNG}", GLOB_BRACE);
foreach($images as $image)
echo "{image : 'http://localhost/uploads/" . $image . "', title : '" .$image . "'},"; ?>

]
});
});
</script>

关于javascript - 无法包含 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14352118/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com